[Help] Formspecs [Solved]

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

[Help] Formspecs [Solved]

by MarkSill » Sun May 05, 2013 21:55

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?
 

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

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

by MarkSill » Mon May 06, 2013 22:29

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
Location: Germany
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Mon May 06, 2013 22:47

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.
 

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

by MarkSill » Mon May 06, 2013 23:22

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

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

by leetelate » Mon Sep 16, 2013 02:08

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: 736
Joined: Sun Jan 26, 2014 17:01
Location: Lyon, France
GitHub: Gael-de-Sailly
IRC: Gael-de-Sailly
In-game: Gael-de-Sailly Ginkgoo

by Gael de Sailly » Wed Mar 26, 2014 18:26

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

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

by Krock » Wed Mar 26, 2014 18:29

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>
 


Return to WIP Mods



Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron