Page 1 of 1

[Help] Formspecs [Solved]

PostPosted: Sun May 05, 2013 21:55
by MarkSill
Hello there. I am needing some help with formspecs.
I can't seem to find a tutorial on them anywhere, and I can't seem to understand it by looking at other's code. Could someone please give me a quick overview of them or something similar?
Thanks!

PostPosted: Mon May 06, 2013 05:13
by sfan5

PostPosted: Mon May 06, 2013 22:29
by MarkSill
Yeah, I looked at that, but where would it go in the code?

PostPosted: Mon May 06, 2013 22:47
by PilzAdam
MarkSill wrote:Yeah, I looked at that, but where would it go in the code?

Depends what formspec you want to have. If you want a node to have a formspec that opens on a rightclick, then you have to set it in the metadata. Default chests do this in on_construct(): https://github.com/minetest/common/blob/master/mods/default/init.lua#L1774

When you want to change the player's formspec, then you would call player:set_inventory_formspec(param) in register_on_joinplayer() with the formspec string as param.

PostPosted: Mon May 06, 2013 23:22
by MarkSill
PilzAdam wrote:
MarkSill wrote:Yeah, I looked at that, but where would it go in the code?

Depends what formspec you want to have. If you want a node to have a formspec that opens on a rightclick, then you have to set it in the metadata. Default chests do this in on_construct(): https://github.com/minetest/common/blob/master/mods/default/init.lua#L1774

When you want to change the player's formspec, then you would call player:set_inventory_formspec(param) in register_on_joinplayer() with the formspec string as param.


Thanks so much!

PostPosted: Mon Sep 16, 2013 02:08
by leetelate
if you're searching for formspec and button, here is an example of a chest-type formspec with 2 buttons,one "take all" and one "put all"
i would have been very happy to find this an hour ago - as said above, the formspec docs do need a bit of a cleanup by someone who really understands them - they may be precise and accurate but lack understanding

junk_chest_formspec =
"size[8,10]"..
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]"..
"button[2,4;2,1;;zbutton;put all]"..
"button[5,4;2,1;;zbutton;take all]"

makes the standard chest inventory screen but with two buttons 'take all' and 'put all'

and so,

on_receive_fields = function(pos, formname, fields, sender)
if fields.zbutton == "put all" then...
if fields.zbutton == "take all" then...
end,

prints "take all" when the take all button is clicked, and 'put all" when the put all button is clicked

PostPosted: Wed Mar 26, 2014 18:26
by Gael de Sailly
The lua_api has changed. Now, Formspec is at https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L869.

PostPosted: Wed Mar 26, 2014 18:29
by Krock
leetelate 2013-09-16 03:08:14 (Last post)
[Help] Formspecs [Solved]

Eh sorry, but how do you get the ideas to dig out SOLVED problems?