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: .window file with multiple scripts - disambiguation  (Read 5293 times)

0 Members and 1 Guest are viewing this topic.

Slav

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
.window file with multiple scripts - disambiguation
« on: March 09, 2011, 08:17:38 PM »

Hello.
I write Flash (ActionScript3) bind for WME and faced the puzzle:
.window file contains two scripts:
Quote
SCRIPT = dialog.script
SCRIPT = mini_game.script
and both of them contain "init()" function - which one must be called when window's function init() is called? May be both of them?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: .window file with multiple scripts - disambiguation
« Reply #1 on: March 09, 2011, 08:42:34 PM »

I don't understand the question. Those are your custom functions so you must know if you want to call them and when.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Slav

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: .window file with multiple scripts - disambiguation
« Reply #2 on: March 09, 2011, 09:41:39 PM »

Sorry for confusing.
I know which function must be called - but my Flash port does not. Which one will be called within original WME engine? By which rules WME chooses a script to call it's function? Searches from end to start (call last one) (so it will looks like "inheritance")?
Thank you.

P.S. I write Flash port for already released C++ (original WME) game - so it is possible to hack .script file in such a way that needed function will be called (other one is just empty) but there are tons of .script and .window files - I will not be able to edit all of them (and, anyway, Flash port must work fine).
« Last Edit: March 09, 2011, 09:47:52 PM by Slav »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: .window file with multiple scripts - disambiguation
« Reply #3 on: March 09, 2011, 09:50:08 PM »

If it's a local function (declared with "function") it can only be called from within the script itself, so it's never ambiguous. If it's a public function (declared with "method") and called from the outside, the one from the last script is called.

In your case, if both scripts contain a method called "init", and you call window.init(), the method from mini_game.scritpt will be called. That way you can override methods by adding a new script on top of existing ones.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Slav

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: .window file with multiple scripts - disambiguation
« Reply #4 on: March 09, 2011, 09:52:48 PM »

It's "method".
Just like I thought.
Thank you!
Logged

Jose

  • Regular poster
  • ***
  • Karma: 2
  • Offline Offline
  • Posts: 134
    • View Profile
Re: .window file with multiple scripts - disambiguation
« Reply #5 on: April 25, 2011, 02:16:03 AM »

So "method" and "function" have nothing to do with returning values or not but with the scope?

I thought that the methods never return any value and function do. But reading this thread I realize that the difference between both is that functions are local to the script were they're defined and methods are public, am I right?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: .window file with multiple scripts - disambiguation
« Reply #6 on: April 25, 2011, 08:17:16 AM »

Yes, that's right.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Jose

  • Regular poster
  • ***
  • Karma: 2
  • Offline Offline
  • Posts: 134
    • View Profile
Re: .window file with multiple scripts - disambiguation
« Reply #7 on: April 25, 2011, 04:55:54 PM »

Thanks Mnemonic
Logged
 

Page created in 0.042 seconds with 24 queries.