allow to load a different file

This commit is contained in:
AFCMS 2021-07-19 23:58:41 +02:00
parent 8f1c543794
commit 0bb9ecd798
3 changed files with 12 additions and 2 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.mods/formspec_edit/formspec.spec

View file

@ -12,6 +12,12 @@ local modpath = minetest.get_modpath("formspec_edit")
local insecure_env = minetest.request_insecure_environment()
local update_time = tonumber(minetest.settings:get("formspec_editor.update_time")) or 0.2
--Load provided file if present
local filepath = minetest.settings:get("formspec_editor.file_path")
if not filepath or filepath == "" then
filepath = modpath .. "/formspec.spec"
end
local error_formspec = [[
formspec_version[4]
size[8,2]
@ -70,7 +76,7 @@ end
-----------------------------------
load_formspec = function()
local io = insecure_env.io
local file = io.open(modpath .. "/formspec.spec", "rb")
local file = io.open(filepath, "rb")
if file == nil then
return error_formspec
else

View file

@ -1,2 +1,5 @@
# Formspec update time (in seconds)
formspec_editor.update_time (Update time) float 0.2
formspec_editor.update_time (Update time) float 0.2
# Path to the default font.
formspec_editor.file_path (File path) filepath