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: Global region's events handling  (Read 4694 times)

0 Members and 1 Guest are viewing this topic.

ylegrand

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 13
  • Keep trying
    • View Profile
Global region's events handling
« on: July 08, 2017, 08:22:09 PM »

Hi WME community!

I'm currently working on my first WME game and I'm facing to a problematic I'm not able to solve myself.

In my scene, there are floors and ladders. I'm able to change the actor animation for the ladder by creating for each ladder region the following dedicated script :

Code: [Select]
on "ActorEntry"
{
actor.WalkAnimName ="ladder";
}
on "ActorLeave"
{
actor.WalkAnimName ="walk";
}

It works fine, but as I'll have a lot of ladders, I was wondering if there is a way to add an event listener on ALL the regions, and to code the conditionnal logic inside. I have in mind to :
  • Add a property "ladder" to every ladder regions (Custom > Properties)
  • Create either way this "magic-global-region-event-listener" and use something like:
Code: [Select]
on "ActorEntry"
{
 if (this.ladder != null){
actor.WalkAnimName ="ladder";
  }
}

First of all, does it make sense to the WME profesionnal you are?
If yes, could you please help me to do it ?

Thanks a lot for your time !
« Last Edit: July 08, 2017, 08:55:41 PM by ylegrand »
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Global region's events handling
« Reply #1 on: July 09, 2017, 01:20:33 PM »

Instead, why not create a single ladder.script and use the first piece of code you showed us in that script? Then you would assign this same script to all your ladder regions. If you want one of your ladder regions to do something different than the other ladders on ActorEntry then you can use the custom properties to program the behaviour.

Good luck with your first WME game!
Logged

ylegrand

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 13
  • Keep trying
    • View Profile
Re: Global region's events handling
« Reply #2 on: July 09, 2017, 01:34:11 PM »

Thanks for your quick answer!

It's indeed a good compromise. I'll do like this by waiting to know if a global region's events listener exists or not.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Global region's events handling
« Reply #3 on: July 09, 2017, 01:45:24 PM »

No, there is no global event listener for this. But I believe anarchist's suggestion is a very valid replacement.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

ylegrand

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 13
  • Keep trying
    • View Profile
Re: Global region's events handling
« Reply #4 on: July 09, 2017, 02:17:17 PM »

So thanks guys, question solved :)
Logged
 

Page created in 0.018 seconds with 23 queries.