//clearobjects doesn't remove unknown objects #6575

Open
opened 2024-03-27 01:46:28 +00:00 by yourland-report · 10 comments

rheo reports a bug:

i can't remove unknown objects that i created w/ minetest.add_entity using //remove or with custom snippets. they just sit there as unknown objects i can see, but don't register as existing programatically

Player position:

{
	y = 57.625999450684,
	z = 609.22204589844,
	x = 1261.5119628906
}

Player look:

{
	y = -0.31647697091103,
	z = -0.8776541352272,
	x = -0.35995206236839
}

Player information:

{
	formspec_version = 7,
	max_rtt = 3.8259999752045,
	major = 5,
	version_string = "5.9.0-dev-454dd8576-dirty",
	state = "Active",
	minor = 9,
	ip_version = 6,
	min_rtt = 0.17499999701977,
	max_jitter = 3.6480000019073,
	patch = 0,
	avg_jitter = 0.00099998712539673,
	connection_uptime = 97,
	serialization_version = 29,
	avg_rtt = 0.18099999427795,
	protocol_version = 42,
	lang_code = "",
	min_jitter = 0
}

Player meta:

{
	fields = {
		["petz:werewolf_vignette_id"] = "16",
		hud_state = "off",
		["unified_inventory:bags"] = "return {\"unified_inventory:bag_large\", \"unified_inventory:bag_large\", \"unified_inventory:bag_large\", \"unified_inventory:bag_large\"}",
		["3d_armor_inventory"] = "return {\"3d_armor:boots_quickfall\", \"\", \"\", \"\", \"\", \"\"}",
		yl_church = "return {[\"last_death\"] = {[\"y\"] = 15, [\"x\"] = 1353, [\"z\"] = 1089}}",
		arenalib_infobox_arenaID = "0",
		partychat = "party",
		["ethereal:fly_timer"] = "-99",
		played_time = "8686639",
		digged_nodes = "22020",
		placed_nodes = "21283",
		died = "2",
		yl_commons_player_created = "1644205752",
		yl_commons_player_joined = "1711503905",
		repellant = "0",
		["ocean_build.last_warning"] = "1.66814e+09",
		["ocean_build.ocean_built"] = "6",
		["petz:werewolf"] = "0",
		["petz:lycanthropy"] = "0",
		jointime = "1644205752",
		bitten = "0",
		["petz:old_override_table"] = "return {[\"sneak\"] = true, [\"speed\"] = 2, [\"new_move\"] = true, [\"jump\"] = 1.5, [\"gravity\"] = 1, [\"sneak_glitch\"] = false}",
		["signslib:pos"] = "(20048,20012,19963)",
		crafted = "2229",
		yl_commons_thankyou = "117",
		punch_count = "1311",
		hotbar_size = "16",
		inflicted_damage = "296090",
		["stamina:level"] = "0",
		["petz:werewolf_clan_idx"] = "2",
		xp = "0",
		["hud_manager:spawnit:hud_enabled"] = "y",
		["stamina:exhaustion"] = "105.5",
		["stamina:poisoned"] = "no"
	}
}

Log identifier


[MOD] yl_report log identifier = rLcjl4r1FcfiehiXj26KGcUz0AdDRDoM

Profiler save:

profile-20240327T014628.json_prettyEE

Status:

# Server: version: 5.7.0-yl-thx-tmm | game: Minetest Game | uptime: 2d 12h 22min 43s | max lag: 1.04s | clients (18/52): AliasAlreadyTaken, Archibald, Bailiff, Cashia, Crazylad, Diaeresis, flux, jackofthebean000, LeetPeet, LockePickens, Miche, nakama-ta, Oakenshield, rheo, RileyB, Service, shoes767, Squawk

Teleport command:

/teleport xyz 1262 58 609

Compass command:

/give_compass Construction rLcjl4r1FcfiehiXj26KGcUz0AdDRDoM D2691E 1262 58 609
rheo reports a bug: > i can't remove unknown objects that i created w/ `minetest.add_entity` using `//remove` or with custom snippets. they just sit there as unknown objects i can see, but don't register as existing programatically Player position: ``` { y = 57.625999450684, z = 609.22204589844, x = 1261.5119628906 } ``` Player look: ``` { y = -0.31647697091103, z = -0.8776541352272, x = -0.35995206236839 } ``` Player information: ``` { formspec_version = 7, max_rtt = 3.8259999752045, major = 5, version_string = "5.9.0-dev-454dd8576-dirty", state = "Active", minor = 9, ip_version = 6, min_rtt = 0.17499999701977, max_jitter = 3.6480000019073, patch = 0, avg_jitter = 0.00099998712539673, connection_uptime = 97, serialization_version = 29, avg_rtt = 0.18099999427795, protocol_version = 42, lang_code = "", min_jitter = 0 } ``` Player meta: ``` { fields = { ["petz:werewolf_vignette_id"] = "16", hud_state = "off", ["unified_inventory:bags"] = "return {\"unified_inventory:bag_large\", \"unified_inventory:bag_large\", \"unified_inventory:bag_large\", \"unified_inventory:bag_large\"}", ["3d_armor_inventory"] = "return {\"3d_armor:boots_quickfall\", \"\", \"\", \"\", \"\", \"\"}", yl_church = "return {[\"last_death\"] = {[\"y\"] = 15, [\"x\"] = 1353, [\"z\"] = 1089}}", arenalib_infobox_arenaID = "0", partychat = "party", ["ethereal:fly_timer"] = "-99", played_time = "8686639", digged_nodes = "22020", placed_nodes = "21283", died = "2", yl_commons_player_created = "1644205752", yl_commons_player_joined = "1711503905", repellant = "0", ["ocean_build.last_warning"] = "1.66814e+09", ["ocean_build.ocean_built"] = "6", ["petz:werewolf"] = "0", ["petz:lycanthropy"] = "0", jointime = "1644205752", bitten = "0", ["petz:old_override_table"] = "return {[\"sneak\"] = true, [\"speed\"] = 2, [\"new_move\"] = true, [\"jump\"] = 1.5, [\"gravity\"] = 1, [\"sneak_glitch\"] = false}", ["signslib:pos"] = "(20048,20012,19963)", crafted = "2229", yl_commons_thankyou = "117", punch_count = "1311", hotbar_size = "16", inflicted_damage = "296090", ["stamina:level"] = "0", ["petz:werewolf_clan_idx"] = "2", xp = "0", ["hud_manager:spawnit:hud_enabled"] = "y", ["stamina:exhaustion"] = "105.5", ["stamina:poisoned"] = "no" } } ``` Log identifier ``` [MOD] yl_report log identifier = rLcjl4r1FcfiehiXj26KGcUz0AdDRDoM ``` Profiler save: ``` profile-20240327T014628.json_prettyEE ``` Status: ``` # Server: version: 5.7.0-yl-thx-tmm | game: Minetest Game | uptime: 2d 12h 22min 43s | max lag: 1.04s | clients (18/52): AliasAlreadyTaken, Archibald, Bailiff, Cashia, Crazylad, Diaeresis, flux, jackofthebean000, LeetPeet, LockePickens, Miche, nakama-ta, Oakenshield, rheo, RileyB, Service, shoes767, Squawk ``` Teleport command: ``` /teleport xyz 1262 58 609 ``` Compass command: ``` /give_compass Construction rLcjl4r1FcfiehiXj26KGcUz0AdDRDoM D2691E 1262 58 609 ```
AliasAlreadyTaken was assigned by yourland-report 2024-03-27 01:46:28 +00:00
flux added the
1. kind/bug
3. source/unknown
labels 2024-03-27 16:33:43 +00:00
flux added the
3. source/engine
label 2024-03-27 16:37:42 +00:00
Member
  1. create a bad entity, e.g. //lua minetest.add_entity(worldedit.pos1.rheo, "bad_entity")
  2. re-mark //1 and //2, and try to remove it using //clearobjects. nothing happens.
local p1, p2 = worldedit.pos1.rheo:sort(worldedit.pos2.rheo)
for _, o in ipairs(minetest.get_objects_in_area(p1, p2)) do
 local e = o:get_luaentity()
 if e then
  print(e.name)
 end
end

emits just image

local count = 0
for i, ent in pairs(minetest.luaentities) do
 if ent.name == "bad_entity" then
  count = count + 1
 end
end
print(count)

emits 0

count = 0
for i, o in pairs(minetest.object_refs) do
 local e = o:get_luaentity()
 if e and e.name == "bad_entity" then
  count = count + 1
 end
end
print(count)

emits 0

1. create a bad entity, e.g. `//lua minetest.add_entity(worldedit.pos1.rheo, "bad_entity")` 1. re-mark `//1` and `//2`, and try to remove it using `//clearobjects`. nothing happens. ```lua local p1, p2 = worldedit.pos1.rheo:sort(worldedit.pos2.rheo) for _, o in ipairs(minetest.get_objects_in_area(p1, p2)) do local e = o:get_luaentity() if e then print(e.name) end end ``` emits just ![image](/attachments/291c3644-51db-4c83-a8a7-c311dd63c3f9) ```lua local count = 0 for i, ent in pairs(minetest.luaentities) do if ent.name == "bad_entity" then count = count + 1 end end print(count) ``` emits `0` ```lua count = 0 for i, o in pairs(minetest.object_refs) do local e = o:get_luaentity() if e and e.name == "bad_entity" then count = count + 1 end end print(count) ``` emits `0`
2.9 KiB
Member

punching the bad entity removes it... but this doesn't work well if you accidentally created hundreds of them...

punching the bad entity removes it... but this doesn't work well if you accidentally created hundreds of them...
Member

if you believe in docs that list remove() under Lua entity only (no-op for other objects)
then you can just do:

local p1, p2 = worldedit.pos1.rheo:sort(worldedit.pos2.rheo)
for _, o in ipairs(minetest.get_objects_in_area(p1, p2)) do
 local e = o:get_luaentity()
 if not e then
  o:remove()
 end
end

Which makes 0 sense, but seems to work.

if you believe in docs that list `remove()` under `Lua entity only (no-op for other objects)` then you can just do: ```lua local p1, p2 = worldedit.pos1.rheo:sort(worldedit.pos2.rheo) for _, o in ipairs(minetest.get_objects_in_area(p1, p2)) do local e = o:get_luaentity() if not e then o:remove() end end ``` Which makes 0 sense, but seems to work.
Member

Also, deprecated get_entity_name() works on them:

local p1, p2 = worldedit.pos1.rheo:sort(worldedit.pos2.rheo)
for _, o in ipairs(minetest.get_objects_in_area(p1, p2)) do
 if o:get_entity_name() == "bad_entity" then
  o:remove()
 end
end

API feels incomplete to me...

Also, deprecated `get_entity_name()` works on them: ```lua local p1, p2 = worldedit.pos1.rheo:sort(worldedit.pos2.rheo) for _, o in ipairs(minetest.get_objects_in_area(p1, p2)) do if o:get_entity_name() == "bad_entity" then o:remove() end end ``` API feels incomplete to me...
flux added
1. kind/documentation
5. result/fixed
and removed
1. kind/bug
3. source/engine
3. source/unknown
labels 2024-03-27 19:28:12 +00:00
AliasAlreadyTaken was unassigned by flux 2024-03-27 19:28:16 +00:00
Member

i figured out how to remove them right before i was about to submit an engine issue:

for i, o in pairs(minetest.object_refs) do
 if not (o:is_player() or o:get_luaentity()) then
  o:remove()
 end
end
i figured out how to remove them right before i was about to submit an engine issue: ```lua for i, o in pairs(minetest.object_refs) do if not (o:is_player() or o:get_luaentity()) then o:remove() end end ```
flux closed this issue 2024-03-27 19:28:54 +00:00
Member

Makes no sense that you can create them and they would have name stored/assigned, but the only way to get this name is deprecated.

Makes no sense that you can create them and they would have name stored/assigned, but the only way to get this name is deprecated.
Member

Makes no sense that you can create them and they would have name stored/assigned, but the only way to get this name is deprecated.

oh, i didn't see your replies before i closed this. possibly a better solution would be

for _, o in ipairs(minetest.get_objects_in_area(p1, p2)) do
 if not (o:is_player() or o:get_luaentity()) then
  o:remove()
 end
end

get_entity_name is reasonably deprecated. i can also see why you wouldn't be able to get the luaentity for an unknown object - for one, the metatable would be ill-defined. also, this is almost certainly the solution to #3601, though i don't know how NPC Amanda showed up as a culprit.

> Makes no sense that you can create them and they would have name stored/assigned, but the only way to get this name is deprecated. oh, i didn't see your replies before i closed this. possibly a better solution would be ```lua for _, o in ipairs(minetest.get_objects_in_area(p1, p2)) do if not (o:is_player() or o:get_luaentity()) then o:remove() end end ``` `get_entity_name` is reasonably deprecated. i can also see why you wouldn't be able to get the luaentity for an unknown object - for one, the metatable would be ill-defined. also, this is almost certainly the solution to #3601, though i don't know how NPC Amanda showed up as a culprit.
Member
upstream PR https://github.com/Uberi/Minetest-WorldEdit/pull/244
flux reopened this issue 2024-03-28 01:54:23 +00:00
flux added
1. kind/bug
3. source/mod upstream
4. step/blocked
and removed
1. kind/documentation
labels 2024-03-28 01:54:35 +00:00
flux added this to the flux's TODO list project 2024-03-28 01:54:39 +00:00
flux self-assigned this 2024-03-28 01:54:44 +00:00
flux changed title from rheo reports: i can't remove unknown objects ... to rheo reports: ~~i can't remove unknown objects~~ 2024-03-28 01:55:14 +00:00
flux changed title from rheo reports: ~~i can't remove unknown objects~~ to //clearobjects doesn't remove unknown objects 2024-03-28 01:55:33 +00:00
flux removed the
5. result/fixed
label 2024-03-29 22:57:52 +00:00
flux added
4. step/ready to QA test
and removed
4. step/blocked
labels 2024-04-03 19:48:04 +00:00
flux added this to the 1.1.124 milestone 2024-04-03 19:48:08 +00:00
Member

upstream was merged.

upstream was merged.
AliasAlreadyTaken added the
ugh/QA NOK
label 2024-04-22 11:50:32 +00:00

QA

For some reason I can't remove the entity, the fix clearly is in.

QA For some reason I can't remove the entity, the fix clearly is in.
Sign in to join this conversation.
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#6575
No description provided.