Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: ActorEntry & ActorLeave for single Actor  (Read 4751 times)

0 Members and 1 Guest are viewing this topic.

Deydren

  • never sleeping
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 7
  • NomNomNom
    • View Profile
ActorEntry & ActorLeave for single Actor
« on: August 18, 2011, 10:02:35 PM »

Hello! Look's like I've run into a problem here... and I'm terribly stuck...

I want to trigger an boolean variable, if my main actor enters or leaves some regions. I've let the various regions trigger it, by attaching the same script to all of them, in which I define an ActorEntry- and ActorLeave-trigger. This far, no problem.
Now I have added a second character, that walks around the screen - and of course, cuz he is an "Actor" too, he also triggers the ActorEntry and -Leave events.  ::thumbdown

Is there a way to let ONLY the player actor trigger the events? Or some work-around?!

Help me, please. It's drivin' me crazy...  ::slug ::slug ::slug
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: ActorEntry & ActorLeave for single Actor
« Reply #1 on: August 18, 2011, 11:03:33 PM »

onw simple way would be to attach a small test after the actor entry event, based on the actors xy coordinate


eg

on "ActorEntry"

{
   if ((actor.X > 300) && (actor.X < 350 ))
     {
         if((actor.Y >100) && (actor.Y < 295))
          { 
           /// do something

         }
     }
}

clumsy and you would need to handcraft it for every activity, and not move the region around
Logged

Deydren

  • never sleeping
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 7
  • NomNomNom
    • View Profile
Re: ActorEntry & ActorLeave for single Actor
« Reply #2 on: August 18, 2011, 11:19:18 PM »

thank you for the fast awnser! but it cannot work this way, 'cause also the second actor's move-pattern changes dynamically and so there are no specific entry points - but that would be necessary for your idea to work.  :(
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: ActorEntry & ActorLeave for single Actor
« Reply #3 on: August 19, 2011, 01:10:23 PM »

not at all,

you have two actors - your main actor and a secondary actor.  actor is the game main object and always referred to as "actor" as per the code snippet above.

Your secondary actor is loaded something like

var other_actor = Game.LoadActor(".....");

we are not testing other_actor.X


therefore his X/Y coordinate is not being tested, only the main actors, maybe you are getting confused between ActorEntry the event and actor the variable
Logged

Deydren

  • never sleeping
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 7
  • NomNomNom
    • View Profile
Re: ActorEntry & ActorLeave for single Actor
« Reply #4 on: August 19, 2011, 01:22:30 PM »

Ah! All right, now I get it :) But there is still the problem, that the script should work on various regions, not only one specific... So, a coordinate-based solution, isn't flexible enough.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: ActorEntry & ActorLeave for single Actor
« Reply #5 on: August 20, 2011, 09:11:06 AM »

You can (and should) use the Scene.GetRegionAt() method. SoMething like:

Code: WME Script
  1. on "ActorEntry"
  2. {
  3.   if (Scene.GetRegionAt(actor1.X, actor1.Y) == this) Game.Msg("actor 1 is in region");
  4. }
  5.  
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.052 seconds with 22 queries.