Once again, I have hit a brick wall with my dungeon.
I've searched a few similar threads about the onDie function, specifically:
viewtopic.php?f=14&t=3239
viewtopic.php?f=14&t=3784#p38693
viewtopic.php?f=14&t=3885
These were helpful for steering me in the right direction but most of these related to having a single monster trigger a door to open.
What I would like is a little different. I'd like a door to open only after 3 monsters have been killed.
I could take the easy route and just have one of the monsters trigger the door on death, but then I don't learn anything and it's a bit awkard.
Here are the steps I took:
SpoilerShow
1) I set up a counter in my dungeon with an initial value of 3. I named the counter monsterDoor
2) I placed a door. I set its ID as: monsterdeadDoor
3) I cloned a snail in the monsters.lua document with the code below. 3 of these cloned snails were added to my dungeon.
4) Created a script_entity in the dungeon*.
5) I also created a pressure plate connected to another script entity to verify that the counter value was decreasing with each monster death.
*I have also tried connecting this script to a button and a timer that triggers every 1 second. Doesn't make a difference.
2) I placed a door. I set its ID as: monsterdeadDoor
3) I cloned a snail in the monsters.lua document with the code below. 3 of these cloned snails were added to my dungeon.
Code: Select all
cloneObject{
name="SnailDoor",
baseObject="snail",
onDie=function(monster)
monsterDoor:decrement()
end
}Code: Select all
function monsterOpen()
monsterDoor:getValue()
if monsterDoor == 0 then
monsterdeadDoor:open()
else
monsterdeadDoor:close()
end
end
Code: Select all
function printCounter()
print(monsterDoor:getValue())
end
*I have also tried connecting this script to a button and a timer that triggers every 1 second. Doesn't make a difference.
It doesn't matter if I use a connector from the counter to the door without the script_entity, a button/timer to trigger the script_entity, or any other combination, the door refuses to open.
Any insights or advice would be appreciated.
Thanks.