From 6bfc943b01ec6526912df78236b5848b766a2c8b Mon Sep 17 00:00:00 2001 From: John Fanjoy Date: Mon, 1 Apr 2024 16:41:02 -0400 Subject: [PATCH] adds a new chat command and column to forceload formspec --- basic_machines/forceload.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/basic_machines/forceload.lua b/basic_machines/forceload.lua index 3a9d55f..3d3c180 100644 --- a/basic_machines/forceload.lua +++ b/basic_machines/forceload.lua @@ -124,13 +124,14 @@ local function formspec(name) tRes[#tRes+1] = minetest.formspec_escape(P2S(pos)) tRes[#tRes+1] = minetest.formspec_escape(P2S(pos1)) tRes[#tRes+1] = minetest.formspec_escape(P2S(pos2)) + tRes[#tRes+1] = minetest.forceload_block(pos, true) and 'Loaded' or 'Unloaded' end return "size[9,9]".. default.gui_bg.. default.gui_bg_img.. default.gui_slots.. "label[0,0;"..S("List of your Forceload Blocks:").."]".. - "tablecolumns[text,width=1.8;text,width=12;text,width=12;text,width=12]".. + "tablecolumns[text,width=1.8;text,width=12;text,width=12;text,width=12;text,width=12]".. "table[0,0.6;8.8,8.4;output;"..table.concat(tRes, ",")..";1]" end end @@ -310,3 +311,21 @@ minetest.register_chatcommand("forceload", { end end, }) + +minetest.register_chatcommand("forceload_verify", { + params = "", + description = "Checks each forceload block and returns a count of active/placed blocks", + func = function(name, param) + local player = minetest.get_player_by_name(name) + if player then + local loaded = {} + local wanted = get_pos_list(player) + for _,pos in ipairs(wanted) do + if minetest.forceload_block(pos, true) then + loaded[#loaded+1] = pos + end + end + minetest.chat_send_player(name, "Found "..#loaded.." out of ".. #wanted .. " force loads") + end + end, +})