Killing spawned monsters
Posted: Sun Oct 07, 2012 3:43 am
I'm having a bit of trouble with killing (not destroying) a spawned monster. In my case a cube. I have it so the player steps on a hidden pressure plate spawning a cube around the corner. In the same block that contains the hidden pressure plate I have one more that's connected to a script_entity. I want the cube to be killed once it touches the second hidden pressure plate. I've tried Monster:setHealth(0), however, I can't seem to find the cube's ID.
This was posted before, but it assigns a random ID on every run. I tried running the second script Grimwold posted that I've edited to suit my needs, but that just crashed the editor.
If I use i:setHealth(0) instead of i:destroy() it doesn't do anything.
This is the error it gives when it crashes.
Any and all help would be greatly appreciated. Thanks in advance
This was posted before, but it assigns a random ID on every run. I tried running the second script Grimwold posted that I've edited to suit my needs, but that just crashed the editor.
Code: Select all
function killCube()
for i in entitiesAt(1,6,14) do
if i.name == "cube"
then
i:destroy()
end
end
end
This is the error it gives when it crashes.
SpoilerShow
[string "Cube.lua"]:0: attempt to index field 'map' (a nil value)
stack traceback:
[string "Cube.lua"]: in function 'crushEntities'
[string "Cube.lua"]: in function 'update'
[string "Monster.lua"]: in function 'update'
[string "Map.lua"]: in function 'updateEntities'
[string "Dungeon.lua"]: in function 'updateLevels'
[string "GameMode.lua"]: in function 'update'
[string "DungeonEditor.lua"]: in main chunk
[C]: in function 'xpcall'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk
stack traceback:
[C]: in function 'error'
[string "DungeonEditor.lua"]: in function 'handleError'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'
stack traceback:
[string "Cube.lua"]: in function 'crushEntities'
[string "Cube.lua"]: in function 'update'
[string "Monster.lua"]: in function 'update'
[string "Map.lua"]: in function 'updateEntities'
[string "Dungeon.lua"]: in function 'updateLevels'
[string "GameMode.lua"]: in function 'update'
[string "DungeonEditor.lua"]: in main chunk
[C]: in function 'xpcall'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk
stack traceback:
[C]: in function 'error'
[string "DungeonEditor.lua"]: in function 'handleError'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'