convert lavalamps to use param2 coloring
Side effect: Now all of Unified Dyes' colors can be applied.
@ -1,24 +1,14 @@
|
|||||||
local lavalamps_list = {
|
|
||||||
{ "Red Lava Lamp", "red"},
|
|
||||||
{ "Orange Lava Lamp", "orange"},
|
|
||||||
{ "Yellow Lava Lamp", "yellow"},
|
|
||||||
{ "Green Lava Lamp", "green"},
|
|
||||||
{ "Blue Lava Lamp", "blue"},
|
|
||||||
{ "Violet Lava Lamp", "violet"},
|
|
||||||
}
|
|
||||||
|
|
||||||
for i in ipairs(lavalamps_list) do
|
lavalamp = {}
|
||||||
local lavalampdesc = lavalamps_list[i][1]
|
|
||||||
local colour = lavalamps_list[i][2]
|
|
||||||
|
|
||||||
minetest.register_node("lavalamp:"..colour, {
|
minetest.register_node("lavalamp:lavalamp", {
|
||||||
description = lavalampdesc,
|
description = "Lava Lamp",
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
mesh = "lavalamp.obj",
|
mesh = "lavalamp.obj",
|
||||||
tiles = {
|
tiles = {
|
||||||
"lavalamp_metal.png",
|
{ name = "lavalamp_metal.png", color = 0xffffffff},
|
||||||
{
|
{
|
||||||
name="lavalamp_lamp_anim_"..colour..".png",
|
name="lavalamp_lamp_anim.png",
|
||||||
animation={
|
animation={
|
||||||
type="vertical_frames",
|
type="vertical_frames",
|
||||||
aspect_w=40,
|
aspect_w=40,
|
||||||
@ -27,9 +17,10 @@ for i in ipairs(lavalamps_list) do
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
inventory_image = "lavalamp_lamp_"..colour.."_inv.png",
|
inventory_image = "lavalamp_lamp_inv.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "color",
|
||||||
|
palette = "unifieddyes_palette.png",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
light_source = 14,
|
light_source = 14,
|
||||||
@ -39,23 +30,31 @@ for i in ipairs(lavalamps_list) do
|
|||||||
},
|
},
|
||||||
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
|
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
node.name = "lavalamp:"..colour.."_off"
|
local itemname = itemstack:get_name()
|
||||||
minetest.set_node(pos, node)
|
if string.find(itemname, "dye:") or string.find(itemname, "unifieddyes:") then
|
||||||
|
unifieddyes.on_rightclick(pos, node, clicker,
|
||||||
|
itemstack, pointed_thing, "lavalamp:lavalamp", false)
|
||||||
|
else
|
||||||
|
node.name = "lavalamp:lavalamp_off"
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("lavalamp:"..colour.."_off", {
|
minetest.register_node("lavalamp:lavalamp_off", {
|
||||||
description = lavalampdesc.." off",
|
description = "Lava Lamp (off)",
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
mesh = "lavalamp.obj",
|
mesh = "lavalamp.obj",
|
||||||
tiles = {
|
tiles = {
|
||||||
"lavalamp_metal.png",
|
{ name = "lavalamp_metal.png", color = 0xffffffff },
|
||||||
"lavalamp_lamp_off.png",
|
"lavalamp_lamp_off.png",
|
||||||
},
|
},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "color",
|
||||||
|
palette = "unifieddyes_palette.png",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
@ -64,21 +63,73 @@ for i in ipairs(lavalamps_list) do
|
|||||||
},
|
},
|
||||||
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, not_in_creative_inventory=1},
|
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3, not_in_creative_inventory=1},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
drop = "lavalamp:"..colour,
|
drop = "lavalamp:lavalamp",
|
||||||
|
after_dig_node = unifieddyes.after_dig_node,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
node.name = "lavalamp:"..colour
|
node.name = "lavalamp:lavalamp"
|
||||||
minetest.set_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "lavalamp:"..colour,
|
output = "lavalamp:lavalamp",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "wool:"..colour, "", },
|
{"", "wool:white", "", },
|
||||||
{"", "bucket:bucket_water", "", },
|
{"", "bucket:bucket_water", "", },
|
||||||
{"", "wool:black", "", }
|
{"", "wool:black", "", }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- convert to param2 coloring
|
||||||
|
|
||||||
|
local colors = {
|
||||||
|
"red",
|
||||||
|
"orange",
|
||||||
|
"yellow",
|
||||||
|
"green",
|
||||||
|
"blue",
|
||||||
|
"violet"
|
||||||
|
}
|
||||||
|
|
||||||
|
lavalamp.old_static_nodes = {}
|
||||||
|
for _, color in ipairs(colors) do
|
||||||
|
table.insert(lavalamp.old_static_nodes, "lavalamp:"..color)
|
||||||
|
table.insert(lavalamp.old_static_nodes, "lavalamp:"..color.."_off")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print(dump(lavalamp.old_static_nodes))
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
name = "lavalamp:convert",
|
||||||
|
label = "Convert lava lamps to use param2 color",
|
||||||
|
run_at_every_load = true,
|
||||||
|
nodenames = lavalamp.old_static_nodes,
|
||||||
|
action = function(pos, node)
|
||||||
|
local name = node.name
|
||||||
|
local newname
|
||||||
|
local color
|
||||||
|
|
||||||
|
if string.find(name, "red") then
|
||||||
|
color = "red"
|
||||||
|
elseif string.find(name, "orange") then
|
||||||
|
color = "orange"
|
||||||
|
elseif string.find(name, "yellow") then
|
||||||
|
color = "yellow"
|
||||||
|
elseif string.find(name, "green") then
|
||||||
|
color = "green"
|
||||||
|
elseif string.find(name, "blue") then
|
||||||
|
color = "blue"
|
||||||
|
elseif string.find(name, "violet") then
|
||||||
|
color = "violet"
|
||||||
|
end
|
||||||
|
|
||||||
|
local paletteidx, _ = unifieddyes.getpaletteidx("unifieddyes:"..color, false)
|
||||||
|
print("LAVALAMP: "..node.name..", "..color.." ("..paletteidx..")")
|
||||||
|
|
||||||
|
minetest.set_node(pos, { name = "lavalamp:lavalamp", param2 = paletteidx })
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("dye", "unifieddyes:"..color)
|
||||||
|
|
||||||
|
end
|
||||||
|
})
|
||||||
|
BIN
lavalamp/textures/lavalamp_lamp_anim.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 82 B After Width: | Height: | Size: 86 B |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.9 KiB |