Development Test Curtain Mod Problem

Rhys
Member
 
Posts: 379
Joined: Wed May 22, 2013 15:22

Development Test Curtain Mod Problem

by Rhys » Mon Apr 21, 2014 09:47

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):
Image
This is when the curtain has been punched (is open but uses dummy texture):
Image
This is when the curtain has been punched again (is closed):
Image
This is when the curtain has been punched again (is open but uses dummy texture):
Image

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.
 

User avatar
CraigyDavi
Member
 
Posts: 582
Joined: Sat Aug 10, 2013 13:08
Location: Hampshire, UK
GitHub: davisonio
IRC: davisonio
In-game: CraigyDavi

Re: Development Test Curtain Mod Problem

by CraigyDavi » Mon Apr 21, 2014 10:23

You have set it to tile invisible.png and that file does not seem to exist.
 

Rhys
Member
 
Posts: 379
Joined: Wed May 22, 2013 15:22

Re: Development Test Curtain Mod Problem

by Rhys » Mon Apr 21, 2014 10:46

CraigyDavi wrote:You have set it to tile invisible.png and that file does not seem to exist.


I mean, the rotation of the curtain I don't want to happen, I've just done a dummy invisible.png, that's all.
 

User avatar
Topywo
Member
 
Posts: 1721
Joined: Fri May 18, 2012 20:27

Re: Development Test Curtain Mod Problem

by Topywo » Mon Apr 21, 2014 12:04

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!
 

Rhys
Member
 
Posts: 379
Joined: Wed May 22, 2013 15:22

Re: Development Test Curtain Mod Problem

by Rhys » Mon Apr 21, 2014 12:51

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!


Thanks very much Topywo, long time no see to reply to one of my posts. :)
 

Rhys
Member
 
Posts: 379
Joined: Wed May 22, 2013 15:22

Re: Development Test Curtain Mod Problem

by Rhys » Mon Apr 21, 2014 14:36

I don't know where to put that code Topywo, could you help me find the place?
 

User avatar
Topywo
Member
 
Posts: 1721
Joined: Fri May 18, 2012 20:27

Re: Development Test Curtain Mod Problem

by Topywo » Mon Apr 21, 2014 19:01

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:

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 ;-)
 

Rhys
Member
 
Posts: 379
Joined: Wed May 22, 2013 15:22

Re: Development Test Curtain Mod Problem

by Rhys » Tue Apr 22, 2014 08:28

Topywo wrote:
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:

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 ;-)


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. :)
 

Rhys
Member
 
Posts: 379
Joined: Wed May 22, 2013 15:22

Re: Development Test Curtain Mod Problem

by Rhys » Tue Apr 22, 2014 10:04

Worked perfectly, thanks Topywo! Just time to now.... Uh... MAKE MORE CURTAINS! :D
 

User avatar
ShadowNinja
Developer
 
Posts: 199
Joined: Tue Jan 22, 2013 22:35
GitHub: ShadowNinja
IRC: ShadowNinja
In-game: ShadowNinja

Re: Development Test Curtain Mod Problem

by ShadowNinja » Wed Apr 23, 2014 02:21

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)
The best way to contact me is usually IRC (InchraNet, freenode).
 

Rhys
Member
 
Posts: 379
Joined: Wed May 22, 2013 15:22

Re: Development Test Curtain Mod Problem

by Rhys » Fri Apr 25, 2014 09:55

ShadowNinja 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)


I've already finished the mod with the code Topywo gave me. I'm glad we have Copy and Paste. xD
 

User avatar
Topywo
Member
 
Posts: 1721
Joined: Fri May 18, 2012 20:27

Re: Development Test Curtain Mod Problem

by Topywo » Fri Apr 25, 2014 12:09

Rhys wrote:
ShadowNinja 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)


I've already finished the mod with the code Topywo gave me. I'm glad we have Copy and Paste. xD


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 ;-) )
 


Return to Problems



Who is online

Users browsing this forum: No registered users and 1 guest

cron