How do I convert my scripts from old to new syntax?

From OHRRPGCE-Wiki
(Redirected from New syntax)
Jump to: navigation, search

You don't need to[edit]

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.

But if you want to anyway...[edit]

Let us demonstrate by example. Suppose you have a script like this:

A simple plotscript[edit]

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.

important![edit]

If you are using the old version Xocolatl+2 or older, 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. If you are using a current stable version, script triggers for old-style scripts that are converted to new-style scripts will automatically be updated.

A script with arguments[edit]

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.

Script ID numbers[edit]

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)

See Also[edit]