Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Attached method executing in parallel?  (Read 2500 times)

0 Members and 1 Guest are viewing this topic.

creatorbri

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 61
  • I'm a llama!
    • View Profile
Attached method executing in parallel?
« on: February 13, 2004, 05:23:54 AM »

Here's my left-click (Interact) handler for a locked chest object:

Code: [Select]
on "Interact"
{
  actor.GoToObject(self);
 
  // Notebook: Found a very old chest.
  actor.Say ("It's locked!");
}

Obviously the actor should walk to the chest, and then say his line. But sometimes, he skips the GoToObject entirely and just says "It's locked." It works correctly with every other click... the first click always skips, the second click waits for the GoToObject, the third skips, etc.

I tried replacing the line 3 call to my custom GoToObject method with the standard GoTo, and it worked fine.

Here's the GoToObject method:

Code: [Select]
method GoToObject (theObj)
{
  this.GoTo (theObj.standX, theObj.standY);
  this.TurnTo (theObj.Direction);
  if (actor.X == theObj.standX && actor.Y == theObj.standY)
    return true;
  else
    return false;
}
Any ideas what's going on?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Attached method executing in parallel?
« Reply #1 on: February 13, 2004, 08:44:55 AM »

Well, it may be a little controversial, but it's by design. Every method call starts a new "thread". So does your GoToObject. The actor is walking, but when you click again, you're telling him to do something else. Actor's walking thread is terminated and the old chest script continues. You could check the return value of the GoToObject method. If it's null, the thread has been interrupted.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.023 seconds with 18 queries.