Hi there,
I have been trying to define functions in my scripts to encapsulate some pieces of code and make cleaner scripts, but I had some problems calling the wait(sec) command from inside a function.
For what I believe (please someone correct me if Im wrong) every script on sexscripts is a ss.FullScript java object, and like every java object it has a wait() method to synchronize threads. The sexscripts script object overrides this method to implement his own wait(sec) command, and everytime we call it from a script, the the sexscripts built-in wait() is executed.
But I realized that if I call wait(sec) from inside a function, the original wait() method is executed cause when I run the script an IllegalMonitorStateException is thrown. for example, in the following code this exception is thrown:
Code:
setInfos(1, "testWait", "Wait call from function testing", "wololo", "started", -1, "en", []);
// Function definition
def myWait = {
->
show("Hello world!");
wait(3);
show("");
}
// Script body
setImage(null);
show("");
myWait();
showButton("Exit");
return null;
I can fix that problem by calling the wait() with this.wait(), with this, the built-in sexscripts wait is executed:
Code:
def myWait = {
->
show("Hello world!");
this.wait(3);
show("");
}
I don't understand why in the first case the original wait it's called, I think that the built-in wait should be called. does someone know why it happens, and how I can do to call the built-in wait with a simple wait(sec); call (without the this.) within a function?