From 6de8e67842c762d54e079c1c048ecdc994457b1b Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 19 Jul 2021 23:21:54 +0200 Subject: [PATCH 01/10] globalstep based formspec updating --- mods/formspec_edit/init.lua | 116 ++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/mods/formspec_edit/init.lua b/mods/formspec_edit/init.lua index 484acd5..e0ea008 100644 --- a/mods/formspec_edit/init.lua +++ b/mods/formspec_edit/init.lua @@ -10,7 +10,8 @@ minetest.register_alias("mapgen_water_source", "air") --Variables local modpath = minetest.get_modpath("formspec_edit") local insecure_env = minetest.request_insecure_environment() -local auto_update_time = 0.2 --seconds +local update_time = 0.2 --seconds + local error_formspec = [[ formspec_version[4] size[8,2] @@ -19,11 +20,17 @@ label[0.375,0.5;Error:formspec.spec is either ] label[0.375,1;non-existent,or empty] ]] +--Crash if not singleplayer +--TODO: hide the 'Host server' checkbox in main menu then possible +if not minetest.is_singleplayer() then + error("[formspec_editor] This game doesn't work in multiplayer!") +end + --function declarations local update_formspec = nil local load_formspec = nil -local auto_update = nil local turn_off_hud = nil +local set_sky --Registrations @@ -32,9 +39,8 @@ local turn_off_hud = nil ----------------------------------- minetest.register_on_joinplayer( function(player_ref,_) - auto_update(player_ref:get_player_name()) - turn_off_hud(player_ref) - set_sky(player_ref) + turn_off_hud(player_ref) + set_sky(player_ref) end ) ----------------------------------- @@ -42,78 +48,82 @@ end ----------------------------------- minetest.register_on_player_receive_fields( function(player_ref, _, fields) - if(fields.quit) then - minetest.request_shutdown() - end - update_formspec(player_ref:get_player_name()) + if(fields.quit) then + minetest.request_shutdown() + end + update_formspec(player_ref:get_player_name()) end ) --function definitions ------------------------------------ ---auto_update() ------------------------------------ -auto_update = function(player_name) - update_formspec(player_name) - minetest.after(auto_update_time,auto_update,player_name) -end - ----------------------------------- --update_formspec() ----------------------------------- update_formspec = function(player_name) - minetest.after(0.1, - function(player_name) - minetest.show_formspec(player_name, "fs", load_formspec()) - end, - player_name) + minetest.after(0.1, + function(player_name) + minetest.show_formspec(player_name, "fs", load_formspec()) + end, + player_name) end ----------------------------------- --load_formspec() ----------------------------------- load_formspec = function() - local io = insecure_env.io - local file = io.open(modpath .. "/formspec.spec", "rb") - if file == nil then - return error_formspec - else - local content = file:read("*all") - file:close() - if content == nil then - return error_formspec - else - return content - end - end + local io = insecure_env.io + local file = io.open(modpath .. "/formspec.spec", "rb") + if file == nil then + return error_formspec + else + local content = file:read("*all") + file:close() + if content == nil then + return error_formspec + else + return content + end + end end ----------------------------------- --turn_off_hud() ----------------------------------- turn_off_hud = function(player_ref) - local flags = { - hotbar = false, - healthbar = false, - crosshair = false, - wielditem = false, - breathbar = false, - minimap = false, - minimap_radar = false, - } - player_ref:hud_set_flags(flags) + local flags = { + hotbar = false, + healthbar = false, + crosshair = false, + wielditem = false, + breathbar = false, + minimap = false, + minimap_radar = false, + } + player_ref:hud_set_flags(flags) end ----------------------------------- --set_sky() ----------------------------------- set_sky = function(player_ref) - local sky = { - base_color = "#AAF", - type = "plain", - clouds = false, - } - player_ref:set_sky(sky) - player_ref:override_day_night_ratio(0) -end \ No newline at end of file + local sky = { + base_color = "#AAF", + type = "plain", + clouds = false, + } + player_ref:set_sky(sky) + player_ref:override_day_night_ratio(0) +end + +local time = 0 +minetest.register_globalstep(function(dtime) + time = time + dtime + if time >= update_time then + local player = minetest.get_connected_players()[1] + if player then + update_formspec(player:get_player_name()) + end + time = 0 + end +end) From 5201b1b7872d4995c8f8d1a1348f36bdb72e1a25 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 19 Jul 2021 23:23:40 +0200 Subject: [PATCH 02/10] fix shadowing var (luacheck) --- mods/formspec_edit/init.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mods/formspec_edit/init.lua b/mods/formspec_edit/init.lua index e0ea008..bdd7922 100644 --- a/mods/formspec_edit/init.lua +++ b/mods/formspec_edit/init.lua @@ -61,11 +61,9 @@ end --update_formspec() ----------------------------------- update_formspec = function(player_name) - minetest.after(0.1, - function(player_name) - minetest.show_formspec(player_name, "fs", load_formspec()) - end, - player_name) + minetest.after(0.1, function(name) + minetest.show_formspec(name, "fs", load_formspec()) + end, player_name) end ----------------------------------- From 2db9151099a4707100a224b655d0d67d1dbd5344 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 19 Jul 2021 23:25:29 +0200 Subject: [PATCH 03/10] add luacheck workflow --- .github/workflows/main.yml | 25 +++++++++++++++++++++ .luacheckrc | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 .luacheckrc diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b955d14 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,25 @@ +name: luacheck + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + + workflow_dispatch: + +jobs: + main: + runs-on: ubuntu-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE + - uses: actions/checkout@v2 + - name: luacheck + uses: nebularg/actions-luacheck@v1.1.0 + #with: + #files: # optional, default is . + #path: # optional, default is ${{ github.workspace }} + #args: # optional + #config: # optional + #annotate: # optional, default is none \ No newline at end of file diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..07485c1 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,45 @@ +read_globals = { + "DIR_DELIM", "INIT", + + "minetest", "core", + "dump", "dump2", + + "Raycast", + "Settings", + "PseudoRandom", + "PerlinNoise", + "VoxelManip", + "SecureRandom", + "VoxelArea", + "PerlinNoiseMap", + "PcgRandom", + "ItemStack", + "AreaStore", + + "vector", + + table = { + fields = { + "copy", + "indexof", + "insert_all", + "key_value_swap", + "shuffle", + } + }, + + string = { + fields = { + "split", + "trim", + } + }, + + math = { + fields = { + "hypot", + "sign", + "factorial" + } + }, +} \ No newline at end of file From 1f9fc8cb4912a91369418c95161d75ee28f47b54 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 19 Jul 2021 23:28:22 +0200 Subject: [PATCH 04/10] add some configuration files --- .editorconfig | 9 +++++++++ .gitattributes | 2 ++ 2 files changed, 11 insertions(+) create mode 100755 .editorconfig create mode 100644 .gitattributes diff --git a/.editorconfig b/.editorconfig new file mode 100755 index 0000000..b58478e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +[*] +end_of_line = lf + +[*.{lua,spec}] +charset = utf8 +indent_size = 4 +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..eba1110 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto \ No newline at end of file From 0dfd44266ac34d242f13445fa63b078fa5913192 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 19 Jul 2021 23:36:25 +0200 Subject: [PATCH 05/10] make update_time depend of a setting --- mods/formspec_edit/init.lua | 2 +- settingtypes.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 settingtypes.txt diff --git a/mods/formspec_edit/init.lua b/mods/formspec_edit/init.lua index bdd7922..894ece3 100644 --- a/mods/formspec_edit/init.lua +++ b/mods/formspec_edit/init.lua @@ -10,7 +10,7 @@ minetest.register_alias("mapgen_water_source", "air") --Variables local modpath = minetest.get_modpath("formspec_edit") local insecure_env = minetest.request_insecure_environment() -local update_time = 0.2 --seconds +local update_time = tonumber(minetest.settings:get("formspec_editor.update_time")) or 0.2 local error_formspec = [[ formspec_version[4] diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..321094f --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +# Formspec update time (in seconds) +formspec_editor.update_time (Update time) float 0.2 \ No newline at end of file From 8f1c5437942d606c77b4c6a9ef551e2d89f70ab2 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 19 Jul 2021 23:40:27 +0200 Subject: [PATCH 06/10] remove unuseful formspec field according to documentation of `position[]` element in `lua_api.txy` --- mods/formspec_edit/init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/mods/formspec_edit/init.lua b/mods/formspec_edit/init.lua index 894ece3..76f809c 100644 --- a/mods/formspec_edit/init.lua +++ b/mods/formspec_edit/init.lua @@ -15,7 +15,6 @@ local update_time = tonumber(minetest.settings:get("formspec_editor.update_time" local error_formspec = [[ formspec_version[4] size[8,2] -position[0.5,0.5] label[0.375,0.5;Error:formspec.spec is either ] label[0.375,1;non-existent,or empty] ]] From 0bb9ecd7980ac5e3a6e03505a40fbdae7971aec9 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 19 Jul 2021 23:58:41 +0200 Subject: [PATCH 07/10] 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 From b0be851f2dd35b8c7f693b4861a80a680f4395f5 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 20 Jul 2021 00:48:51 +0200 Subject: [PATCH 08/10] mcl2 and mtg styling support --- README.md | 8 +- mods/formspec_edit/init.lua | 134 +++++++++++------- mods/formspec_edit/textures/CREDITS.md | 9 ++ .../mcl2/mcl_base_textures_background9.png | Bin 0 -> 171 bytes .../textures/mcl2/mcl_inventory_button9.png | Bin 0 -> 86 bytes .../mcl2/mcl_inventory_button9_pressed.png | Bin 0 -> 86 bytes .../textures/mtg/mtg_gui_formbg.png | Bin 0 -> 886 bytes settingtypes.txt | 7 +- 8 files changed, 104 insertions(+), 54 deletions(-) create mode 100644 mods/formspec_edit/textures/CREDITS.md create mode 100644 mods/formspec_edit/textures/mcl2/mcl_base_textures_background9.png create mode 100644 mods/formspec_edit/textures/mcl2/mcl_inventory_button9.png create mode 100644 mods/formspec_edit/textures/mcl2/mcl_inventory_button9_pressed.png create mode 100644 mods/formspec_edit/textures/mtg/mtg_gui_formbg.png diff --git a/README.md b/README.md index 748008a..4ecd9a5 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,14 @@ The file *formspec.spec* in your: ```minetest_folder/games/formspec_editor/mods/formspec_edit``` -contains a formspec you can edit and see updates of in real time. +contains a formspec you can edit and see updates of in real time. (You can also specify a file location with the `formspec_editor.file_path` setting.) Simply add the game to MT, load up a level of *Formspec Editor*, and -you will be greeted with the *formspec.spec* formspec. +you will be greeted with the formspec. -- To make edits, open the file (formspec.spec) in your editor of choice and make changes as you see fit. When you hit save, the formspec will auto-update. Best when used side by side. +- To make edits, open the file in your editor of choice and make changes as you see fit. When you hit save, the formspec will auto-update. Best when used side by side. - To exit just hit or use a button_exit[] button. Both send the fields.quit message. - You can test with images if you want, adding a "textures" folder to the formspec_edit gamemod folder, otherwise images will default to random colors. +- You can show the formspec with builtin, minetest_game or mineclone2 styling (see the `formspec_editor.style` setting) +- You can change the refresh rate by changing the `formspec_editor.update_time` setting diff --git a/mods/formspec_edit/init.lua b/mods/formspec_edit/init.lua index 4ec4af5..5a38e08 100644 --- a/mods/formspec_edit/init.lua +++ b/mods/formspec_edit/init.lua @@ -10,6 +10,7 @@ minetest.register_alias("mapgen_water_source", "air") --Variables local modpath = minetest.get_modpath("formspec_edit") local insecure_env = minetest.request_insecure_environment() +local io = insecure_env.io local update_time = tonumber(minetest.settings:get("formspec_editor.update_time")) or 0.2 --Load provided file if present @@ -18,6 +19,12 @@ if not filepath or filepath == "" then filepath = modpath .. "/formspec.spec" end +--Get styling presets +local styling = minetest.settings:get("formspec_editor.style") +if not styling or styling == "" then + styling = "builtin" +end + local error_formspec = [[ formspec_version[4] size[8,2] @@ -31,51 +38,12 @@ if not minetest.is_singleplayer() then error("[formspec_editor] This game doesn't work in multiplayer!") end ---function declarations -local update_formspec = nil -local load_formspec = nil -local turn_off_hud = nil -local set_sky - ---Registrations - ------------------------------------ ---on_joinplayer() ------------------------------------ -minetest.register_on_joinplayer( -function(player_ref,_) - turn_off_hud(player_ref) - set_sky(player_ref) -end -) ------------------------------------ ---on_player_receive_fields() ------------------------------------ -minetest.register_on_player_receive_fields( -function(player_ref, _, fields) - if(fields.quit) then - minetest.request_shutdown() - end - update_formspec(player_ref:get_player_name()) -end -) - --function definitions ------------------------------------ ---update_formspec() ------------------------------------ -update_formspec = function(player_name) - minetest.after(0.1, function(name) - minetest.show_formspec(name, "fs", load_formspec()) - end, player_name) -end - ----------------------------------- --load_formspec() ----------------------------------- -load_formspec = function() - local io = insecure_env.io +local function load_formspec() local file = io.open(filepath, "rb") if file == nil then return error_formspec @@ -90,11 +58,58 @@ load_formspec = function() end end +----------------------------------- +--update_formspec() +----------------------------------- +local function update_formspec(player_name) + minetest.after(0.1, function(name) + minetest.show_formspec(name, "fs", load_formspec()) + end, player_name) +end + +----------------------------------- +--apply_styling() +----------------------------------- +local function apply_styling(player_ref) + local prepend = "" + if styling == "minetest_game" then + ------------------------------------------------ + ---------------Minetest Game code--------------- + ------------------------------------------------ + prepend = [[ + bgcolor[#080808BB;true] + listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] + ]] + local name = player_ref:get_player_name() + local info = minetest.get_player_information(name) + if info.formspec_version > 1 then + prepend = prepend .. "background9[5,5;1,1;mtg_gui_formbg.png;true;10]" + else + prepend = prepend .. "background[5,5;1,1;mtg_gui_formbg.png;true]" + end + elseif styling == "mineclone2" then + ------------------------------------------------ + ---------------MineClone2 code------------------ + ------------------------------------------------ + --Sadly, this code doesn't support inventory slot styling (texture based) + prepend = "listcolors[#9990;#FFF7;#FFF0;#000;#FFF]".. + "style_type[image_button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]".. + "style_type[button;border=false;bgimg=mcl_inventory_button9.png;bgimg_pressed=mcl_inventory_button9_pressed.png;bgimg_middle=2,2]".. + "style_type[field;textcolor=#323232]".. + "style_type[label;textcolor=#323232]".. + "style_type[textarea;textcolor=#323232]".. + "style_type[checkbox;textcolor=#323232]".. + "bgcolor[#00000000]".. + "background9[1,1;1,1;mcl_base_textures_background9.png;true;7]" + end + player_ref:set_formspec_prepend(prepend) +end + ----------------------------------- --turn_off_hud() ----------------------------------- -turn_off_hud = function(player_ref) - local flags = { +local function turn_off_hud(player_ref) + player_ref:hud_set_flags({ hotbar = false, healthbar = false, crosshair = false, @@ -102,28 +117,49 @@ turn_off_hud = function(player_ref) breathbar = false, minimap = false, minimap_radar = false, - } - player_ref:hud_set_flags(flags) + }) end ----------------------------------- --set_sky() ----------------------------------- -set_sky = function(player_ref) - local sky = { +local function set_sky(player_ref) + player_ref:set_sky({ base_color = "#AAF", type = "plain", clouds = false, - } - player_ref:set_sky(sky) + }) + player_ref:set_stars({visible = false}) + player_ref:set_sun({visible = false}) + player_ref:set_moon({visible = false}) player_ref:override_day_night_ratio(0) end +--Registrations + +----------------------------------- +--on_joinplayer() +----------------------------------- +minetest.register_on_joinplayer(function(player_ref,_) + apply_styling(player_ref) + turn_off_hud(player_ref) + set_sky(player_ref) +end) +----------------------------------- +--on_player_receive_fields() +----------------------------------- +minetest.register_on_player_receive_fields(function(player_ref, _, fields) + if fields.quit then + minetest.request_shutdown() + end + update_formspec(player_ref:get_player_name()) +end) + local time = 0 minetest.register_globalstep(function(dtime) time = time + dtime if time >= update_time then - local player = minetest.get_connected_players()[1] + local player = minetest.get_connected_players()[1] --The game isn't supposed to work in multiplayer if player then update_formspec(player:get_player_name()) end diff --git a/mods/formspec_edit/textures/CREDITS.md b/mods/formspec_edit/textures/CREDITS.md new file mode 100644 index 0000000..15fba50 --- /dev/null +++ b/mods/formspec_edit/textures/CREDITS.md @@ -0,0 +1,9 @@ +These textures are copied from Minetest Game and MineClone2 projects + +# Minetest Game (CC BY-SA 3.0) +mtg_gui_formbg.png + +# MineClone2 (CC BY-SA 3.0) +mcl_inventory_button9.png +mcl_inventory_button9_pressed.png +mcl_base_textures_background9.png \ No newline at end of file diff --git a/mods/formspec_edit/textures/mcl2/mcl_base_textures_background9.png b/mods/formspec_edit/textures/mcl2/mcl_base_textures_background9.png new file mode 100644 index 0000000000000000000000000000000000000000..e5d693e7bd6a27fa99323c3de445df733b9562c0 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^S|H591|*LjJ{b+9iacE$Ln;{G-ehDuV8GM*P}cnT z*4g(63sfyap1t!|H+g#Kg7_V|8RyRQU2|k@ zaA;&=FlZTXjTVb{s3P3AivIlo~mUV2pV*8hT=K-(ES MUHx3vIVCg!0D-7Nr2qf` literal 0 HcmV?d00001 diff --git a/mods/formspec_edit/textures/mcl2/mcl_inventory_button9.png b/mods/formspec_edit/textures/mcl2/mcl_inventory_button9.png new file mode 100644 index 0000000000000000000000000000000000000000..aab16013b47ede51604f2b017b6436f3f1a806b5 GIT binary patch literal 86 zcmeAS@N?(olHy`uVBq!ia0vp^Y#_|R1SIpm&(4{Cd$BDu7kV~z<`N0Q3g$$mqelF{r5}E)2mKE** literal 0 HcmV?d00001 diff --git a/mods/formspec_edit/textures/mtg/mtg_gui_formbg.png b/mods/formspec_edit/textures/mtg/mtg_gui_formbg.png new file mode 100644 index 0000000000000000000000000000000000000000..e259fec2e21e7c837f5cc0ebd8b61002936a9932 GIT binary patch literal 886 zcmeAS@N?(olHy`uVBq!ia0y~yVEh2YzgU=oB3zQpn}L*8fKP}kkj4aBT3RM1CQM9B zyu7@kqM{xi9=5i&Kf3So0+n)<1o;IEGB9$e*}84IR^wj8z`*p`)5S5Q;?~>ChJLpb zB#uAy?>hQ#Cbz(Irmz}D{zkqv1|nf9dI1Z)WEj{a7CvI~NXfIF!d=2)?OY^o_noD) z<%-7p&y&l4U%a1x%F_Ixlz6e<(YvnM3zoY^pKrZ5`ngm`Jag9NC4Y;g*RI~D{o$2`%%5jTCI`+RKA2zc z*82Zd^P&3h$pw^y4{saiH#WboI{$!1z?%I(m)tUU%3Vr|2_HH>RChNw?=I|a{(be} z!Mi(-LWzTDpq!_UjgLGax564~1<;;?{kw2kaj=}ZjyxOCbp4Zm`1@_4%@60s>u>LU zulNx1VDhV??tL%+?z4Hn`qP@rMPIkY=uXS;ewsA-U!C;RDX+i1D4qLE`s=4HNB_?F z+bkc_zI>zA%jK-|X0P+z_-a>L!}ZB}QD-X}j_c_BVU}9^BIn6evs_T_@pScbS?83{ F1OOs(kO}|* literal 0 HcmV?d00001 diff --git a/settingtypes.txt b/settingtypes.txt index f23715d..fe15730 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,5 +1,8 @@ # Formspec update time (in seconds) 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 +# Path of the formspec file +formspec_editor.file_path (File path) filepath + +# Style type +formspec_editor.style (Formspec style) enum builtin builtin,minetest_game,mineclone2 \ No newline at end of file From 17f1c4a4a5ac8b3023ed5e0fb11743b16e0792c0 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 20 Jul 2021 00:52:23 +0200 Subject: [PATCH 09/10] request insecure env properly --- README.md | 4 ++++ mods/formspec_edit/init.lua | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 4ecd9a5..2e8daa3 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ ## Getting Started +This mod needs access to an insecure environment in order to work. + +Add `formspec_edit` to `secure.trusted_mods` in your `minetest.conf` file. + The file *formspec.spec* in your: ```minetest_folder/games/formspec_editor/mods/formspec_edit``` diff --git a/mods/formspec_edit/init.lua b/mods/formspec_edit/init.lua index 5a38e08..7467797 100644 --- a/mods/formspec_edit/init.lua +++ b/mods/formspec_edit/init.lua @@ -9,7 +9,12 @@ minetest.register_alias("mapgen_water_source", "air") --Variables local modpath = minetest.get_modpath("formspec_edit") + local insecure_env = minetest.request_insecure_environment() +if not insecure_env then + error("[formspec_editor] Cannot access insecure environment!") +end + local io = insecure_env.io local update_time = tonumber(minetest.settings:get("formspec_editor.update_time")) or 0.2 From d9a128d65fd4ec8d91b0f0d392f59bbb171a6ebf Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 20 Jul 2021 00:54:58 +0200 Subject: [PATCH 10/10] fix `.luacheckrc` --- .luacheckrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.luacheckrc b/.luacheckrc index 07485c1..0ae26d3 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,3 +1,5 @@ +max_line_length = false + read_globals = { "DIR_DELIM", "INIT",