Page 1 of 1

Help with spawned entities

Posted: Sun Feb 01, 2015 12:33 pm
by WaspUK1966
I`ve written a code that spawns a monster in front of the party, prints a message and plays some screen/sound effects etc.

Code: Select all

playSound("karim")
party:shakeCamera(0.3, 4)
spawn("karim_ghost", party.level, party.x+3, party.y, 0)
hudPrint("Lord Karim: 'I'm watching you..'")

I've then linked it to a timer which runs a script to make the monster disappear after a few seconds. But I can't figure out what I need to code to make the spawned entity disappear. Just keep getting error messages:

Code: Select all

function removeghost
karim_ghost:destroy()
end
I've tried all sorts of combinations. Any advice?

George

Re: Help with spawned entities

Posted: Sun Feb 01, 2015 1:38 pm
by maneus
You have to give your "karim_ghost" a unique id.
Try this:

playSound("karim")
party:shakeCamera(0.3, 4)
spawn("karim_ghost", party.level, party.x+3, party.y, 0, "karim_ghost_1")
hudPrint("Lord Karim: 'I'm watching you..'")

Then change your function to:

function removeghost()
karim_ghost_1:destroy()
end

Re: Help with spawned entities

Posted: Sun Feb 01, 2015 1:52 pm
by WaspUK1966
Thanks for your reply. As it happens, I`d just figured it out and got it working by giving the monster an ID, and was about to delete the post when I saw your reply! Appreciate your response, though. Thanks again.
George