From e091ca1c43c27338ca9e28ac5b1fd5ab07cf1869 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Fri, 29 Jan 2021 01:16:54 +0100 Subject: [PATCH] Update README --- README.md | 1 + init.lua | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ebfdf32..e34efa1 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ To enable it: `i3_progressive_mode = true` in `minetest.conf`.* - [**`3d_armor`**](https://content.minetest.net/packages/stu/3d_armor/) - [**`skinsdb`**](https://content.minetest.net/packages/bell07/skinsdb/) - [**`awards`**](https://content.minetest.net/packages/rubenwardy/awards/) + - [**`worldedit`**](https://content.minetest.net/packages/sfan5/worldedit/) #### Recommendations diff --git a/init.lua b/init.lua index bb67152..147b884 100644 --- a/init.lua +++ b/init.lua @@ -2538,8 +2538,8 @@ if rawget(_G, "worldedit") then formspec = function(player, _, fs) local name = player:get_player_name() - local wfs = worldedit.pages.worldedit_gui.get_formspec(name) - wfs = split(wfs, "]") + local wfs = split(worldedit.pages.worldedit_gui.get_formspec(name), "]") + local new_fs = {} for i, elem in ipairs(wfs) do if sub(elem, 1, 4) == "size" or sub(elem, 1, 5) == "label" or @@ -2550,19 +2550,16 @@ if rawget(_G, "worldedit") then wfs[i] = wfs[i] .. "]" end - local new_fs = {} - - for i = 1, #wfs do - local elem = wfs[i] - local elem_name, field, str = match(elem, "(.*)%[.*%d+;(.*);(.*)]") + for i, elem in ipairs(wfs) do + local ename, field, str = match(elem, "(.*)%[.*%d+;(.*);(.*)]") local X = i % 3 X = X + (X * 2.42) + 0.2 local Y = floor((i % (#wfs - 1) - X) / 3 + 1) + 1.2 - insert(new_fs, fmt("%s[%.1f,%.1f;3,0.8;%s;%s]", - elem_name, X, Y, field, str:gsub("/", " / "))) + insert(new_fs, fmt("%s[%f,%f;3,0.8;%s;%s]", + ename, X, Y, field, str:gsub("/", " / "))) end fs(concat(new_fs))