mirror of
https://gitlab.com/4w/mtimer.git
synced 2024-11-28 10:13:50 +01:00
31 lines
886 B
Lua
31 lines
886 B
Lua
local m = mtimer
|
|
local f = mtimer.show_formspec
|
|
|
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|
local meta = player:get_meta()
|
|
local name = player:get_player_name()
|
|
|
|
|
|
-- Select what formspec to show basing on main menu button
|
|
if formname == 'mtimer:main_menu' then
|
|
if fields.set_visibility then f.set_visibility(name) end
|
|
end
|
|
|
|
|
|
-- Set timer visibility
|
|
if formname == 'mtimer:set_visibility' then
|
|
local attr = m.meta.visible
|
|
if fields.visible then meta:set_string(attr.key, 'true') end
|
|
if fields.invisible then meta:set_string(attr.key, 'false') end
|
|
if fields.default then meta:set_string(attr.key, attr.default) end
|
|
end
|
|
|
|
|
|
-- Back to menu from all formspecs
|
|
if fields.back then f.menu(name) end
|
|
|
|
|
|
-- DEBUG: Print all player meta data
|
|
print(dump(meta:to_table()))
|
|
end)
|