formspec on_punch

User avatar
juli
Member
 
Posts: 109
Joined: Sat Jun 11, 2016 10:31
GitHub: cpdef
In-game: juli

formspec on_punch

by juli » Mon Jun 13, 2016 06:40

i want to show a formspec if i punch a node.
The problem isn't to show, but to receive_fields:
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
on_punch = function(pos, node, player, pointed_thing)
                         
                        formspec = "size[8,10]" ..
                                "field[channel;Channel;${channel}]" ..      --set channel
                                "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";paper; 3.5,4;1,1;]" ..   --paper stack
                                "label[1,4;Paper]"..
                                "list[current_player;main;0,6;8,4;]"
                        minetest.show_formspec(player:get_player_name(), "formspec", formspec)
                end,

so what must i change, that the node receives the data from the field? (that i can save the channel)
Please tell me if i have written bad english.
Planets/Asteroids mod: https://forum.minetest.net/viewtopic.php?t=15933
servers where i'am:
mars-server
jungle-server
buildersworld
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: formspec on_punch

by TenPlus1 » Mon Jun 13, 2016 08:10

Check out my protector mod, it does exactly what you ask: https://github.com/tenplus1/protector
 

User avatar
juli
Member
 
Posts: 109
Joined: Sat Jun 11, 2016 10:31
GitHub: cpdef
In-game: juli

Re: formspec on_punch

by juli » Mon Jun 13, 2016 18:55

thank you!
Please tell me if i have written bad english.
Planets/Asteroids mod: https://forum.minetest.net/viewtopic.php?t=15933
servers where i'am:
mars-server
jungle-server
buildersworld
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: formspec on_punch

by kaeza » Mon Jun 13, 2016 22:14

If you use `show_formspec`, the fields are sent to registered `on_player_receive_fields` callbacks (you should check that the passed form name matches what you passed to `show_formspec` to ignore forms from other mods). If the formspec is part of the node's `infotext` metadata field, the fields are received in the node's own `on_receive_fields` callback.

Edit: If you go with `show_formspec`, I recommend using the `yourmodname:` prefix for form names to avoid conflicts with other mods' form names.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
juli
Member
 
Posts: 109
Joined: Sat Jun 11, 2016 10:31
GitHub: cpdef
In-game: juli

Re: formspec on_punch

by juli » Tue Jun 14, 2016 14:44

ok.
Please tell me if i have written bad english.
Planets/Asteroids mod: https://forum.minetest.net/viewtopic.php?t=15933
servers where i'am:
mars-server
jungle-server
buildersworld
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron