Merge branch 'fix-markerdupes' into dev

This commit is contained in:
Starbeamrainbowlabs 2023-08-01 00:35:44 +01:00
commit fadf4ed06c
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
10 changed files with 71 additions and 6 deletions

@ -1,6 +1,6 @@
{
"name": "worldeditadditions",
"version": "1.14.4",
"version": "1.14.5",
"description": "Documentation website for WorldEditAdditions",
"main": "index.js",
"private": true,

@ -4,6 +4,10 @@ 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 (1st August 2023)
- 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

@ -1349,6 +1349,17 @@ Here are some more examples:
```
### `//listentities`
Lists all currently loaded ObjectRefs. Displays their IDs, Names (if possible), and possitions.
This command is intended for development and modding. You will not normally need to use this command using WorldEditAdditions.
`//listentities` takes no arguments.
```
//listentities
```
## Extras
<!--

@ -1,6 +1,6 @@
--- WorldEditAdditions
-- @namespace worldeditadditions
-- @release 1.14.4
-- @release 1.14.5
-- @copyright 2023 Starbeamrainbowlabs
-- @license Mozilla Public License, 2.0
-- @author Starbeamrainbowlabs

@ -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")

@ -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
})

@ -18,6 +18,7 @@ local WEAPositionMarker = {
collisionbox = { -0.55, -0.55, -0.55, 0.55, 0.55, 0.55 },
physical = false,
collide_with_objects = false,
hp_max = 1,
textures = {
"worldeditadditions_core_bg.png",
@ -31,6 +32,7 @@ local WEAPositionMarker = {
on_activate = function(self, staticdata)
local data = minetest.parse_json(staticdata)
print("DEBUG:pos_marker ON_ACTIVATE data", data)
if type(data) ~= "table" or data.id ~= last_reset then
-- print("DEBUG:marker_wall/remove staticdata", staticdata, "last_reset", last_reset)
self.object:remove()
@ -52,6 +54,7 @@ local WEAPositionMarker = {
anchor.set_number(self.object, self.display_number)
end,
on_punch = function(self, _)
print("DEBUG:pos_marker on_punch")
anchor.delete(self)
end,
on_blast = function(self, damage)
@ -155,5 +158,5 @@ anchor = EventEmitter.new({
delete = delete,
set_number = set_number
})
anchor.debug = true
return anchor

@ -22,7 +22,8 @@ local WEAPositionMarkerWall = {
-- ^^ { xmin, ymin, zmin, xmax, ymax, zmax } relative to obj pos
physical = false,
collide_with_objects = false,
hp_max = 1,
textures = {
"worldeditadditions_core_marker_wall.png",
"worldeditadditions_core_marker_wall.png",
@ -53,6 +54,7 @@ local WEAPositionMarkerWall = {
})
end,
on_punch = function(self, _)
print("DEBUG:pos_marker_wall on_punch")
anchor.delete(self)
-- Only unmark the rest of the walls
-- Unmark for the player that created this wall.... NOT the player who punched it!

@ -1,6 +1,6 @@
--- WorldEditAdditions-Core
-- @namespace worldeditadditions_core
-- @release 1.14.4
-- @release 1.14.5
-- @copyright 2021 Starbeamrainbowlabs and VorTechnix
-- @license Mozilla Public License, 2.0
-- @author Starbeamrainbowlabs and VorTechnix

@ -58,8 +58,12 @@ end
-- @param event_name string The name of the event to emit.
-- @param args table|any The argument(s) to pass to listener functions. It is strongly advised you pass a table here.
function EventEmitter.emit(this, event_name, args)
if this.debug then
listeners = 0
if this.events[event_name] ~= nil then listeners = #this.events[event_name] end
print("DEBUG:EventEmitter emit", event_name, "listeners", listeners, "args", wea_c.inspect(args))
end
if this.events[event_name] == nil then return end
if this.debug then print("DEBUG:EventEmitter emit", event_name, "args", wea_c.inspect(args)) end
for index,next_func in ipairs(this.events[event_name]) do
next_func(args)