I have a little question:
During my short use of AGS i've realised there are three repeatedly_executed scripts:
-One at global script
-Another one for each room
-And one which I don't know what is for, called repeatedly_executed_always at global script
I need someone to tell me which scipt has the preference.
I mean: if I type "a=2;" at globalscript repeatedly_executed and I type "a=3;" at the room repeatedly_executed script and "a=4;" at repeatedly_executed_always.
Whats "a" value at the end?
Thanks :)
I'm sure someone else will be able to answer you, but I just have to ask - I'd understand, with other functions, the need to know the order in which AGS processes its stuff... but with rep_execute? It's not an issue you're likely to ever need to resolve. Rep_exec is for those things that are repeatedly being executed. For a default gamespeed, that's 40 times per second. In practical terms, you'll hardly ever need it for stuff when you need such definite values.
Here's something you can try yourself - do exactly what you proposed to do in your example, and add, after each line of code, something to make the game display "a" in a GUI label. See what happens.
Again, this is not at all a practical question, due to the intended use of rep_exec. Can you give an example of a case where the priorities could be a relevant factor?
//At global script rep_exec
if(mouse.Mode==eModeInteract)label.Text="Interact with @overhotspot@";
//At room script rep_exec
if(Game.GetLocationName(mouse.x,mouse.y)=="window"){//if mouse is over hotspot window(i dont mind the mouse mode)
label.Text="Look through the window";
}
Not only you replied with a valid example, you just exemplified using code that you can actually use to answer your own question. :) Try that code out and see what happens.
I don't *know* for sure, but I believe room script is processed first and global script last. Not sure. Try out your own example, see what happens.
Right tried it out and room script had preference. ;D
Now, what's the difference between rep_exec and rep_exec_always???
I'm sure that's explained in the manual, but I can understand it's not immediatly obvious to a recent AGSer.
Basically, rep_exec has a catch - it would not run during blocking events. If you had a pop-up GUI displayed, or some object/character was running a blocking animation, or a Display window was on, rep_execute would pause. Rep_exec_always, on the other hand, runs away *all the time*. Use with caution, and sparingly, young Luke.
In the manual under Understanding blocking scripts (http://www.adventuregamestudio.co.uk/manual/BlockingScripts.htm) it explains everything Rui just said. Though it's understandable how getting from "how does rep_ex differ from rep_ex_always" to that page. ;)