Rhys wrote:I don't know where to put that code Topywo, could you help me find the place?
I tried it out, the numbers are right, this should do the trick for the placement of the curtains:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_node("curtains:red_closed", {
description = "Red Curtain",
tiles = {"wool_red.png"},
paramtype = "light",
paramtype2 = "wallmounted",
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
drawtype = "signlike",
walkable = false,
groups = {oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_leaves_defaults(),
on_punch = function(pos, node, clicker)
playername = clicker:get_player_name()
if minetest.is_protected(pos, playername) then
minetest.record_protection_violation(pos, playername)
return
end
if node.name == "curtains:red_closed" and node.param2 == 2 then
minetest.add_node(pos, {name="curtains:red_open", param2 = 2})
elseif node.name == "curtains:red_closed" and node.param2 == 3 then
minetest.add_node(pos, {name="curtains:red_open", param2 = 3})
elseif node.name == "curtains:red_closed" and node.param2 == 4 then
minetest.add_node(pos, {name="curtains:red_open", param2 = 4})
elseif node.name == "curtains:red_closed" and node.param2 == 5 then
minetest.add_node(pos, {name="curtains:red_open", param2 = 5})
end
end
})
minetest.register_node("curtains:red_open", {
description = "Red Curtain",
tiles = {"invisible.png"},
paramtype = "light",
paramtype2 = "wallmounted",
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
drawtype = "signlike",
drop = "curtains:red_closed",
walkable = false,
groups = {oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_leaves_defaults(),
on_punch = function(pos, node, clicker)
playername = clicker:get_player_name()
if minetest.is_protected(pos, playername) then
minetest.record_protection_violation(pos, playername)
return
end
if node.name == "curtains:red_open" and node.param2 == 2 then
minetest.add_node(pos, {name="curtains:red_closed", param2 = 2})
elseif node.name == "curtains:red_open" and node.param2 == 3 then
minetest.add_node(pos, {name="curtains:red_closed", param2 = 3})
elseif node.name == "curtains:red_open" and node.param2 == 4 then
minetest.add_node(pos, {name="curtains:red_closed", param2 = 4})
elseif node.name == "curtains:red_open" and node.param2 == 5 then
minetest.add_node(pos, {name="curtains:red_closed", param2 = 5})
end
end
})
Probably it is also possible to use tabels where you put the colors of your curtains in, that are iterated (if I'm right something like for a = 1, 7 do) into some base code. But tabels, functions and well, coding in general, are not my strongest point, so I write and try everything out until I find some code that is easy to copy and use ;-)