diff --git a/CHANGELOG.md b/CHANGELOG.md index f99247d..6b6e177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ It's about time I started a changelog! This will serve from now on as the main c Note to self: See the bottom of this file for the release template text. +## v1.14.5: The multipoint update, hotfix 5 (unreleased) +- Added `//listentities`, which lists all currently loaded `ObjectRef`s. This is intended for debugging mods. + ## v1.14.4: The multipoint update, hotfix 4 (31st July 2023) - When any segment of the marker wall is punched, unmark the entire wall @@ -11,6 +14,7 @@ Note to self: See the bottom of this file for the release template text. ## v1.14.3: The multipoint update, hotfix 3 (18th July 2023) - Fix regions not remembering their state and being unresettable + ## v1.14.2: The multipoint update, hotfix 2 (15th July 2023) - Fix crash in `//subdivide`, again due to the new position system diff --git a/worldeditadditions_commands/commands/meta/init.lua b/worldeditadditions_commands/commands/meta/init.lua index 30924fb..15ad16c 100644 --- a/worldeditadditions_commands/commands/meta/init.lua +++ b/worldeditadditions_commands/commands/meta/init.lua @@ -16,3 +16,5 @@ dofile(we_cmdpath.."many.lua") dofile(we_cmdpath.."multi.lua") dofile(we_cmdpath.."noiseapply2d.lua") dofile(we_cmdpath.."subdivide.lua") + +dofile(we_cmdpath.."listentities.lua") \ No newline at end of file diff --git a/worldeditadditions_commands/commands/meta/listentities.lua b/worldeditadditions_commands/commands/meta/listentities.lua new file mode 100644 index 0000000..538b964 --- /dev/null +++ b/worldeditadditions_commands/commands/meta/listentities.lua @@ -0,0 +1,39 @@ +-- Lists all currently loaded entities. + +local weac = worldeditadditions_core + +minetest.register_chatcommand("/listentities", { + params = "", + description = + "Lists all currently loaded entities. This is a command for debugging and development. You will not need this unless you are developing a mod.", + privs = { worldedit = true }, + func = function(name, params_text) + local table_vals = { + { "ID", "Name", "Position" }, + { "------", "-------", "---------" }, + } + for id, obj in pairs(minetest.object_refs) do + local obj_name = "[ObjectRef]" + if obj.get_luaentity then + local luaentity = obj:get_luaentity() + if luaentity then + obj_name = "[LuaEntity:"..luaentity.name.."]" + else + obj_name = "[LuaEntity:__UNKNOWN__]" + end + end + local pos = weac.Vector3.clone(obj:get_pos()) + table.insert(table_vals, { + id, + obj_name, + tostring(pos) + }) + end + worldedit.player_notify(name, table.concat({ + "Currently loaded entities:", + weac.format.make_ascii_table(table_vals), + "", + "Total "..tostring(#table_vals).." objects" + }, "\n")) + end +})