Passing object references to Timeouts

I'd like to have a door autoclose after a certain number of real-life seconds. There are probable ways to do this by creating a monitoring object, and having it tick down .. then add that to a list, for all the doors... But that means a lot of management code to ensure I don't add the same thing to the list etc etc.

What I'd really like to be able to do is this in the script:

// So long as we're not already closing
if (not this.isclosing = true) {
 // note that we now are
  this.isclosing = true
  // ... in 5 seconds
   SetTimeoutID(5) {
    // ...close the door
     // ...note that we're no longer closing
     this.isclosing = false

i.e. the door remains open for 5 seconds, and then closes. If anyone attempts to re-run the open script, it's protected from creating yet another close timer....

The issue is that the "this" reference is not recognised.. and I can't think of a way to easily 'store' the "this" reference except in an above-mentioned list of object names which needs to be managed....

Anyone got any good ideas on how you can do this? In fact, since the SetTimeout and timers can't seem to have any form of variable passed into them at creation time, and I can't see a way to 'eval' a string into a script, to 'bake' the name in...

Help! :)

This topic is now closed. Topics are closed after 60 days of inactivity.