plasticbox/init.lua
2017-01-25 12:58:49 -06:00

74 lines
2.2 KiB
Lua

minetest.register_node("plasticbox:plasticbox", {
description = "Plastic Box",
tiles = {"plasticbox_white.png"},
is_ground_content = false,
groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1},
sounds = default.node_sound_stone_defaults(),
paramtype2 = "color",
palette = "unifieddyes_palette.png",
on_destruct = unifieddyes.on_destruct,
on_rightclick = unifieddyes.on_rightclick,
})
stairsplus:register_all("plasticbox", "plasticbox", "plasticbox:plasticbox", {
description = "Plastic",
tiles = {"plasticbox_white.png"},
groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_craft( {
output = "plasticbox:plasticbox 4",
recipe = {
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
{ "homedecor:plastic_sheeting", "", "homedecor:plastic_sheeting" },
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
},
})
minetest.register_lbm({
name = "plasticbox:convert_colors",
label = "Convert plastic boxes to use param2 color",
nodenames = {
"plasticbox:plasticbox_black",
"plasticbox:plasticbox_blue",
"plasticbox:plasticbox_brown",
"plasticbox:plasticbox_cyan",
"plasticbox:plasticbox_green",
"plasticbox:plasticbox_grey",
"plasticbox:plasticbox_magenta",
"plasticbox:plasticbox_orange",
"plasticbox:plasticbox_pink",
"plasticbox:plasticbox_red",
"plasticbox:plasticbox_violet",
"plasticbox:plasticbox_white",
"plasticbox:plasticbox_yellow",
"plasticbox:plasticbox_darkgreen",
"plasticbox:plasticbox_darkgrey",
},
action = function(pos,node)
local conv = {
["black"] = 5,
["blue"] = 73,
["brown"] = 22,
["cyan"] = 57,
["green"] = 41,
["grey"] = 3,
["magenta"] = 89,
["orange"] = 17,
["pink"] = 11,
["red"] = 9,
["violet"] = 81,
["white"] = 1,
["yellow"] = 25,
["darkgreen"] = 46,
["darkgrey"] = 4,
}
local name = node.name
local oldcolor = string.sub(name,string.len("plasticbox:plasticbox_-"),-1)
node.name = "plasticbox:plasticbox"
if conv[oldcolor] then node.param2 = conv[oldcolor] end
minetest.set_node(pos,node)
end,
})