Page 1 of 1

Deleting Object from within its own Script

Posted: Wed Jan 21, 2015 11:56 pm
by Gage
Hello!

Anyone know a way to do the following?

on HandlerName
delete me
end HandlerName

Usually, I do this:

---------------------------------
In Object

on ObjectHandler
put the long id of me into tObject
send "DeleteObject tObject" to card "My Card" in 20 milliseconds
end ObjectHandler

----------------------------------
On the Card

on DeleteMe pObjectID
delete pObjectID
end DeleteMe

-----------------------------------

... or something close to that. However, in this case, my cards will not have the DeleteMe handler on them, hence wanting to "delete me in 20 milliseconds" from the object's own script.


Thanks!
Phil E.

Re: Deleting Object from within its own Script

Posted: Thu Jan 22, 2015 12:04 am
by Da_Elf
i usually do the same and put the deleteme script in the main stack so all cards and objects can access it. mine is setup for deleting single objects as well as sequentially numbered objects

Re: Deleting Object from within its own Script

Posted: Thu Jan 22, 2015 12:08 am
by Klaus
Hi Phil,

you can actually do something like this:

Code: Select all

on mouseup
  put the long ID of me int tID
  send "delete tID" to this stack in 20 millisecs
end mouseup
and the stack (the engine!) knows what to do and will do it! :D


Best

Klaus

Re: Deleting Object from within its own Script

Posted: Thu Jan 22, 2015 1:45 am
by Gage
Klaus,

That's awesome! I didn't realize it accepted a parameter. That's just what I'm looking for; nice and universal.

Thank you both for your responses!
Phil E.