[Help] Formspecs [Solved]

Post Reply
MarkSill
Member
Posts: 12
Joined: Wed Sep 12, 2012 00:18

[Help] Formspecs [Solved]

by MarkSill » Post

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!
Last edited by MarkSill on Wed May 08, 2013 01:05, edited 1 time in total.
Are you a potato?

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

MarkSill
Member
Posts: 12
Joined: Wed Sep 12, 2012 00:18

by MarkSill » Post

Yeah, I looked at that, but where would it go in the code?
Are you a potato?

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

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

MarkSill
Member
Posts: 12
Joined: Wed Sep 12, 2012 00:18

by MarkSill » Post

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 ... .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!
Are you a potato?

leetelate
Member
Posts: 205
Joined: Thu Aug 29, 2013 18:07
Location: 한인 타운, Huntsville,Alabama,USA

by leetelate » Post

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
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...

User avatar
Gael de Sailly
Member
Posts: 845
Joined: Sun Jan 26, 2014 17:01
GitHub: gaelysam
IRC: Gael-de-Sailly
In-game: Gael-de-Sailly gaelysam
Location: Voiron, France

by Gael de Sailly » Post

The lua_api has changed. Now, Formspec is at https://github.com/minetest/minetest/bl ... i.txt#L869.
Just realize how bored we would be if the world was perfect.

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

by Krock » Post

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?
Last edited by Krock on Wed Mar 26, 2014 18:30, edited 1 time in total.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 27 guests