How do I convert my scripts from old to new syntax?
From OHRRPGCE-Wiki
Contents |
[edit] You don't need to
You do not need to convert your scripts to new syntax. Old syntax will continue to work with no changes. You can even mix old and new style scripts in the same file.
[edit] But if you want to anyway...
Let us demonstrate by example. Suppose you have a script like this:
[edit] A simple plotscript
define script(3, my script, none) script, my script, begin # do stuff here end
You no longer need to use a define script to give the script an ID number and arguments. You can delete it completely. Then change script to plotscript.
plotscript, my script, begin # do stuff here end
You no longer need to worry about assigning ID numbers.
[edit] important!
After you convert a script from old style to new style and import it into your game, you need to go back into CUSTOM and re-select the script for the NPC, text box, map, or whatever triggers it. Old style scripts are triggered by ID, but new style scripts are triggered by name, so if you convert an old script it is important that you select your script triggers again.
[edit] A script with arguments
But if there is no more define script needed anymore, how do you specify default arguments? Here is an example of
define script(autonumber,point to tile, 1,0) script, point to tile, point, begin return((point/20)*20) end
In this example, the define script gives the point to tile script one argument which defaults to zero. To do this in a new-style script, you can write:
script, point to tile, point=0, begin return((point/20)*20) end
Now the default is set where it says point=0
Also notice that we did not change script to plotscript. That is because this script is only intended to be triggered from other scripts. New style scripts using plotscript will be available for triggers in custom. Scripts using script will be hidden in custom.
[edit] Script ID numbers
For commands like set death script that expect a script ID number, you can use @name of script instead.
set death script(@my script)
Also, if you are curious what internal ID number has been magically assigned to your script, you can try this:
show value(@my script)
