Wintermute Engine Forum
Wintermute Engine => Technical forum => Topic started by: Slav 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:
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?
-
I don't understand the question. Those are your custom functions so you must know if you want to call them and when.
-
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).
-
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.
-
It's "method".
Just like I thought.
Thank you!
-
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?
-
Yes, that's right.
-
Thanks Mnemonic