Deleting yourself?

All flavors welcome.
Forum rules
Be kind.
Post Reply
User avatar
richmond62
Posts: 4833
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Deleting yourself?

Post by richmond62 »

Imagine a button called "B1" containing the script:

Code: Select all

on mouseUp
delete me
end mouseUp
This will NOT work, and generate the following error message:

Code: Select all

object's script is executing
This IS problematic as I wish to delete an object from inwith its own code if certain conditions are satisfied . . .
https://richmondmathewson.owlstown.net/
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Deleting yourself?

Post by tperry2x »

Yes, you can't delete an object while script is running inside it.

However, you can do this, you just need to send it as a function in x ticks/milliseconds/seconds
(demo stack attached)
Creates a button and deletes itself when you click the button.
delete-test.oxtstack
(792 Bytes) Downloaded 40 times
User avatar
richmond62
Posts: 4833
Joined: Sun Sep 12, 2021 11:03 am
Location: Bulgaria
Contact:

Re: Deleting yourself?

Post by richmond62 »

That is good to know.
https://richmondmathewson.owlstown.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests