Okay, this one is courtesy of Komag
viewtopic.php?f=14&t=3239&hilit=ondie&start=10
His post:
Here is my monsters.lua clone:
Code: Select all
cloneObject{
model = "mod_assets/models/monsters/snail_ben.fbx",
name = "sick_snail",
baseObject = "snail",
health = 2,
sight = 1,
attackPower = 1,
onDie = function(monster)
return sickscript.snaildie()
end
}
and here is my script (named "sickscript") in the editor:
Code: Select all
function snaildie()
diecounter:decrement()
print("you got 'em")
end
I still don't understand how parameters work or quite how the monsters.lua affects this sicksnail script, but it works just how I want now - the counter decrements and in turn triggers the actions I want to happen when the snail dies.
"diecounter: decrement" to "your_door_1: open()
or if that gives you trouble, notice he uses a counter, to trigger to 0 to make things happen through connectors from there