mirror of
https://github.com/ExeVirus/formspec_editor.git
synced 2025-03-14 21:51:24 +00:00
allow to load a different file
This commit is contained in:
parent
8f1c543794
commit
0bb9ecd798
3 changed files with 12 additions and 2 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.mods/formspec_edit/formspec.spec
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Add table
Reference in a new issue