Initial commit

This commit is contained in:
Wuzzy 2016-12-07 13:33:19 +01:00
commit a1bb902e3d
3 changed files with 42 additions and 0 deletions

1
depends.txt Normal file
View File

@ -0,0 +1 @@
sfinv

40
init.lua Normal file
View File

@ -0,0 +1,40 @@
local buttons = {}
local buttons_num = 0
sfinv_buttons = {}
sfinv_buttons.register_button = function(name, def)
buttons[name] = def
buttons_num = buttons_num + 1
end
sfinv.register_page("sfinv_buttons:buttons", {
title = "Buttons",
is_in_nav = function(self, player, context)
return buttons_num > 0
end,
get = function(self, player, context)
local f = ""
local y = 0
for name, def in pairs(buttons) do
f = f .. "button["..
"0,"..y..";3,1;"..
"sfinv_button_"..minetest.formspec_escape(name)..";"..
minetest.formspec_escape(def.title)..
"]"
y = y + 1
end
return sfinv.make_formspec(player, context, f)
end,
on_player_receive_fields = function(self, player, context, fields)
if fields.sfinv_button1 then
minetest.chat_send_player(player:get_player_name(), "Button 1 pressed!")
end
end,
})
-- Test
sfinv_buttons.register_button("button1", { title = "Button 1" })
sfinv_buttons.register_button("button2", { title = "Button 2" })
sfinv_buttons.register_button("button3", { title = "Button 3" })
sfinv_buttons.register_button("button4", { title = "Button 4" })

1
mod.conf Normal file
View File

@ -0,0 +1 @@
name = sfinv_buttons