Development Test Curtain Mod Problem
Development Test Curtain Mod Problem
Hello everybody! Rhys here with a mod failure. I am trying to create a working curtain mod with an on_punch command. The results are very weird. Here are some screenshots of the problem:
This is when the curtain is first placed (is closed):
This is when the curtain has been punched (is open but uses dummy texture):
This is when the curtain has been punched again (is closed):
This is when the curtain has been punched again (is open but uses dummy texture):
Here is also a link to the code:
http://pastebin.com/eLAX6aBH
So, could anybody help me please? Thanks in advance. :)
This is when the curtain is first placed (is closed):
This is when the curtain has been punched (is open but uses dummy texture):
This is when the curtain has been punched again (is closed):
This is when the curtain has been punched again (is open but uses dummy texture):
Here is also a link to the code:
http://pastebin.com/eLAX6aBH
So, could anybody help me please? Thanks in advance. :)
Last edited by Rhys on Mon Apr 21, 2014 11:20, edited 1 time in total.
- CraigyDavi
- Member
- Posts: 582
- Joined: Sat Aug 10, 2013 13:08
- GitHub: davisonio
- IRC: davisonio
- In-game: CraigyDavi
- Location: Hampshire, UK
- Contact:
Re: Development Test Curtain Mod Problem
You have set it to tile invisible.png and that file does not seem to exist.
Re: Development Test Curtain Mod Problem
I mean, the rotation of the curtain I don't want to happen, I've just done a dummy invisible.png, that's all.CraigyDavi wrote:You have set it to tile invisible.png and that file does not seem to exist.
Re: Development Test Curtain Mod Problem
The 'automatic' placement of the node always places it in one specific direction. To put the curtain on another spot, you can use the param2 option.
Example:
minetest.add_node(pos, {name = "curtains:red_open", param2=20})
Then you'll still have the trouble how to place the curtain in the right spot.
For the seamod I use this:
elseif node.name == "stairsshine:stair_seaglass_white" and node.param2 == 21 then
minetest.add_node(pos, {name="stairs:stair_seaglassoff_white", param2 = 21})
nodeupdate(pos)
elseif node.name == "stairs:stair_seaglassoff_white" and node.param2 == 21 then
minetest.add_node(pos, {name="stairsshine:stair_seaglass_white", param2 = 21})
nodeupdate(pos)
elseif node.name == "stairsshine:stair_seaglass_white" and node.param2 == 22 then
minetest.add_node(pos, {name="stairs:stair_seaglassoff_white", param2 = 22})
nodeupdate(pos)
elseif node.name == "stairs:stair_seaglassoff_white" and node.param2 == 22 then
minetest.add_node(pos, {name="stairsshine:stair_seaglass_white", param2 = 22})
nodeupdate(pos)
Though it's possible you need to find/use other numbers than 21 and 22.
For invisible you might consider making a node curtains: red_close. For texture you could copy the 'invisible' part of the default glass texture (at least I do it like that).
Good luck!
Example:
minetest.add_node(pos, {name = "curtains:red_open", param2=20})
Then you'll still have the trouble how to place the curtain in the right spot.
For the seamod I use this:
elseif node.name == "stairsshine:stair_seaglass_white" and node.param2 == 21 then
minetest.add_node(pos, {name="stairs:stair_seaglassoff_white", param2 = 21})
nodeupdate(pos)
elseif node.name == "stairs:stair_seaglassoff_white" and node.param2 == 21 then
minetest.add_node(pos, {name="stairsshine:stair_seaglass_white", param2 = 21})
nodeupdate(pos)
elseif node.name == "stairsshine:stair_seaglass_white" and node.param2 == 22 then
minetest.add_node(pos, {name="stairs:stair_seaglassoff_white", param2 = 22})
nodeupdate(pos)
elseif node.name == "stairs:stair_seaglassoff_white" and node.param2 == 22 then
minetest.add_node(pos, {name="stairsshine:stair_seaglass_white", param2 = 22})
nodeupdate(pos)
Though it's possible you need to find/use other numbers than 21 and 22.
For invisible you might consider making a node curtains: red_close. For texture you could copy the 'invisible' part of the default glass texture (at least I do it like that).
Good luck!
Re: Development Test Curtain Mod Problem
Thanks very much Topywo, long time no see to reply to one of my posts. :)Topywo wrote:The 'automatic' placement of the node always places it in one specific direction. To put the curtain on another spot, you can use the param2 option.
Example:
minetest.add_node(pos, {name = "curtains:red_open", param2=20})
Then you'll still have the trouble how to place the curtain in the right spot.
For the seamod I use this:
elseif node.name == "stairsshine:stair_seaglass_white" and node.param2 == 21 then
minetest.add_node(pos, {name="stairs:stair_seaglassoff_white", param2 = 21})
nodeupdate(pos)
elseif node.name == "stairs:stair_seaglassoff_white" and node.param2 == 21 then
minetest.add_node(pos, {name="stairsshine:stair_seaglass_white", param2 = 21})
nodeupdate(pos)
elseif node.name == "stairsshine:stair_seaglass_white" and node.param2 == 22 then
minetest.add_node(pos, {name="stairs:stair_seaglassoff_white", param2 = 22})
nodeupdate(pos)
elseif node.name == "stairs:stair_seaglassoff_white" and node.param2 == 22 then
minetest.add_node(pos, {name="stairsshine:stair_seaglass_white", param2 = 22})
nodeupdate(pos)
Though it's possible you need to find/use other numbers than 21 and 22.
For invisible you might consider making a node curtains: red_close. For texture you could copy the 'invisible' part of the default glass texture (at least I do it like that).
Good luck!
Re: Development Test Curtain Mod Problem
I don't know where to put that code Topywo, could you help me find the place?
Re: Development Test Curtain Mod Problem
I tried it out, the numbers are right, this should do the trick for the placement of the curtains:Rhys wrote:I don't know where to put that code Topywo, could you help me find the place?
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
})
Re: Development Test Curtain Mod Problem
I see. Before I did do it in the right place, that code, but the copy and paste bit went wrong, and the game gave me a lot of errors, thanks again Topywo. :)Topywo wrote:I tried it out, the numbers are right, this should do the trick for the placement of the curtains:Rhys wrote:I don't know where to put that code Topywo, could you help me find the place?
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 ;-)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 })
Re: Development Test Curtain Mod Problem
Worked perfectly, thanks Topywo! Just time to now.... Uh... MAKE MORE CURTAINS! :D
- ShadowNinja
- Developer
- Posts: 200
- Joined: Tue Jan 22, 2013 22:35
- GitHub: ShadowNinja
- IRC: ShadowNinja
- In-game: ShadowNinja
Re: Development Test Curtain Mod Problem
You have to restore the param2 (and param1) value when you use set_node. You can get your current param1 and param2 values with get_node. You should NOT use a hardcoded param2 value. So, for example.
Code: Select all
local node = minetest.get_node(pos)
node.name = "curtains:red_closed"
minetest.set_node(pos, node)
Re: Development Test Curtain Mod Problem
I've already finished the mod with the code Topywo gave me. I'm glad we have Copy and Paste. xDShadowNinja wrote:You have to restore the param2 (and param1) value when you use set_node. You can get your current param1 and param2 values with get_node. You should NOT use a hardcoded param2 value. So, for example.Code: Select all
local node = minetest.get_node(pos) node.name = "curtains:red_closed" minetest.set_node(pos, node)
Re: Development Test Curtain Mod Problem
I had to smile reading this. But I'm afraid ShadowNinja is right about this. I the near future I will try that code out for my seaglass. When and if it functions okay, I'll make an example for curtains too (to copy/paste ;-) )Rhys wrote:I've already finished the mod with the code Topywo gave me. I'm glad we have Copy and Paste. xDShadowNinja wrote:You have to restore the param2 (and param1) value when you use set_node. You can get your current param1 and param2 values with get_node. You should NOT use a hardcoded param2 value. So, for example.Code: Select all
local node = minetest.get_node(pos) node.name = "curtains:red_closed" minetest.set_node(pos, node)
Who is online
Users browsing this forum: No registered users and 4 guests