Don't register /flow-example in multiplayer

This commit is contained in:
luk3yx 2022-10-14 08:20:17 +13:00
parent f8af81b69a
commit f4d40efe2e
2 changed files with 18 additions and 15 deletions

View File

@ -1,4 +1,4 @@
-- Debugging -- You can run /flow-example in singleplayer to open this form
local gui = flow.widgets local gui = flow.widgets
local elements = {"box", "label", "image", "field", "checkbox", "list"} local elements = {"box", "label", "image", "field", "checkbox", "list"}

View File

@ -969,23 +969,26 @@ function gui_mt.__newindex()
end end
local modpath = minetest.get_modpath("flow") local modpath = minetest.get_modpath("flow")
local example_form if minetest.is_singleplayer() then
minetest.register_chatcommand("flow-example", { local example_form
privs = {server = true}, minetest.register_chatcommand("flow-example", {
help = "Shows an example formspec", privs = {server = true},
func = function(name) help = "Shows an example formspec",
-- Only load example.lua when it's needed func = function(name)
if not example_form then -- Only load example.lua when it's needed
example_form = dofile(modpath .. "/example.lua") if not example_form then
end example_form = dofile(modpath .. "/example.lua")
example_form:show(name) end
end, example_form:show(name)
}) end,
})
end
if DEBUG_MODE then if DEBUG_MODE then
local f, err = loadfile(modpath .. "/test-fs.lua") local f, err = loadfile(modpath .. "/test-fs.lua")
if not f then if f then
return f()
else
minetest.log("error", "[flow] " .. tostring(err)) minetest.log("error", "[flow] " .. tostring(err))
end end
return f()
end end