From 0bb9ecd7980ac5e3a6e03505a40fbdae7971aec9 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 19 Jul 2021 23:58:41 +0200 Subject: [PATCH] allow to load a different file --- .gitignore | 1 + mods/formspec_edit/init.lua | 8 +++++++- settingtypes.txt | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b683fc0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.mods/formspec_edit/formspec.spec \ No newline at end of file diff --git a/mods/formspec_edit/init.lua b/mods/formspec_edit/init.lua index 76f809c..4ec4af5 100644 --- a/mods/formspec_edit/init.lua +++ b/mods/formspec_edit/init.lua @@ -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 diff --git a/settingtypes.txt b/settingtypes.txt index 321094f..f23715d 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,2 +1,5 @@ # Formspec update time (in seconds) -formspec_editor.update_time (Update time) float 0.2 \ No newline at end of file +formspec_editor.update_time (Update time) float 0.2 + +# Path to the default font. +formspec_editor.file_path (File path) filepath \ No newline at end of file