[Mod] Formspec Framework [formspec]
I am working on a mod that hopefully makes working with Formspecs more enjoyable. It gives you more of a programming interface to formspecs rather than just concatenating a bunch of strings. It does some basic auto vertical positioning of elements within the form as well as auto form sizing. Hopefully the auto positioning will get more advanced and I am going to make this work with all formspec elements. View the README on GitHub to see what it currently supports.
Example:

Minecraft Style Inventory
License: LGPL 2.1
Source: https://github.com/bremaweb/formspec
Example:
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
local form = FormSpec({name="dialog"})
form.callback = function(self,player,fields)
if fields.chat then
minetest.chat_send_player(player:get_player_name(),fields.txt)
end
end
local txt = Field({name="txt",label="Enter Text"})
local button = Button({name="chat",label="Chat"})
local button2 = Button({exit=true,name="exit",label="Close"})
form:add(txt)
form:add(button)
form:add(button2)
form:show(player)
Minecraft Style Inventory
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
local form = FormSpec({name="minecraft_inventory"})
form:add(Image({left=1,top=0.6,width=1,height=2,texture="player.png"}))
form:add(PlayerInventory({left=0,top=3.5}))
form:add(CraftInventory({left=3,top=0}))
form:add(List({inv="current_player",list="craftpreview",left=7,top=1}))
form:show(player:get_player_name())
--[[OLD FORMSPEC WAY
size[8,7.5;]
image[1,0.6;1,2;player.png]
list[current_player;main;0,3.5;8,4;]
list[current_player;craft;3,0;3,3;]
list[current_player;craftpreview;7,1;1,1;]
]]
License: LGPL 2.1
Source: https://github.com/bremaweb/formspec