add 'entity.despawn' command

This commit is contained in:
MihailRis
2024-07-17 07:35:02 +03:00
parent c9958c9718
commit 41a22938d6
8 changed files with 41 additions and 5 deletions
+4
View File
@@ -11,6 +11,10 @@ function setup_variables()
if pentity ~= 0 then
console.set('entity.id', pentity)
end
local sentity = player.get_selected_entity(pid)
if sentity ~= nil then
console.set('entity.selected', sentity)
end
end
function on_history_up()
+13
View File
@@ -156,3 +156,16 @@ console.add_command(
return "spawned new player entity #"..tostring(eid)
end
)
console.add_command(
"entity.despawn entity:sel=$entity.selected",
"Despawn entity",
function (args, kwargs)
local eid = args[1]
local entity = entities.get(eid)
if entity ~= nil then
entity:despawn()
return "despawned entity #"..tostring(eid)
end
end
)