Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Ennio on January 15, 2012, 08:31:05 PM

Title: "ActorEntry" event on Region object
Post by: Ennio on January 15, 2012, 08:31:05 PM
I have a strange bug with a trigger region.
This region is activated when an event occured in game, and has a script attached that is executed when the actor entry this region (actorentry event).

I've set the SaveState attribute of this region to true, so when i return the scene, my region is regularly activated, and it's ok...but wherever my actor enters the scene he activates the trigger and the actorEntry event is executed...how is that possibile?
I can't find a solution...
Title: Re: "ActorEntry" event on Region object
Post by: Azrael on January 16, 2012, 09:04:46 AM
There is another actor in the scene that is inside this region?
Title: Re: "ActorEntry" event on Region object
Post by: metamorphium on January 16, 2012, 04:49:58 PM
How does your scene_init.script for that scene look like?
Title: Re: "ActorEntry" event on Region object
Post by: Jose on January 16, 2012, 07:02:05 PM
Hi Ennio,

maybe I don't understand you right but if I do it, I think there isn't any bug in the behavior of the ActorEntry event of the region. Whenever the region is active and the actor entries in that region, the WME engine is going to raise the ActorEntry event for that region and, as far as you have code in the handler of the ActorEntry event for that region, that code will be executed. If you want that code executed only the first time the actor entries the region then you can add a boolean custom property to that region. Let's assume you call that property isFirstTime and you've set its initial value to 'true', then in the code for the ActorEntry event handler you have to ask if isFirstTime is true. If so, then execute the rest of the code and set isFirstTime to false, this way your code will be executed only one time. This will be similar to this code:

Code: WME Script
  1. on "ActorEntry"
  2. {
  3.     if(this.isFirstTime)
  4.     {
  5.          The code you want to execute...
  6.          this.isFirstTime = false;
  7.     }
  8. }
  9.  

Hope this helps.
Title: Re: "ActorEntry" event on Region object
Post by: metamorphium on January 16, 2012, 08:11:26 PM
I am asking specifically because there is default code which might for a short time place actor to that region. :)
Title: Re: "ActorEntry" event on Region object
Post by: Ennio on January 17, 2012, 12:53:12 PM
Ok! thank you for your reply wich were very helpful!

I don't want a region that triggers event only one time, so the problem, according to metamorphium's advise, is that i have a sprite entity that skips to this region in my init scritpt.
So ActorEntry event is activated not only by the actor itself! I did not know  :-[

Will be easy to fix the code now :)
Thank you again!
Title: Re: "ActorEntry" event on Region object
Post by: Jose on January 17, 2012, 11:51:51 PM
Opssss! Shame on me, I confused 'wherever' with 'whenever'  :-[ Me and my fu***ng English  :'(
Title: Re: "ActorEntry" event on Region object
Post by: Ennio on January 18, 2012, 09:34:07 AM
ahhaha don't worry! finally the international language won't be the english, but the chinese, and then the problem will become serious!  :P  :P  :P
Title: Re: "ActorEntry" event on Region object
Post by: metamorphium on January 18, 2012, 01:33:58 PM
你好, glad it worked :)
Title: Re: "ActorEntry" event on Region object
Post by: Ennio on January 18, 2012, 08:57:52 PM
...and metamorphium will be in advantage :P