Scripting help

From OHRRPGCE-Wiki
Jump to navigation Jump to search

There's really more than 1 way to do things in CUSTOM. For example, you could use various switches, which in itself is a form of scripting using conditionals. Switches are very good for teaching coding, because they are comparable to coding functions.

Code works a lot like switches. They both have settings, such as "ON" or "OFF", But you can have other values. Numerical values** can exist in various states, but can represent decimal or percentage etc., The other type is **word values**. If you want to use "Constants", which are basically words that the script interpreter can understand, such as up/down/left/right and north/south/east/west. If you tell an NPC to walk in a "direction" such as named in the constants, it will understand you. Similarly, we can write "one - one" and it will work like "1-1" But we can also name our own constants* and global variables.


Global Variables and Variables and Constants[edit]

Global variables can be accessed by any script. Otherwise they work live variables and you can use name codes for Global Variables (${V1} would display whatever is written in Global Variable 1, during gameplay. I think.) Global Variables exist even when no script is calling it. It exists permanently and can be called anywhere at anytime basically. All scripts can potentially affect it as well.

Constants are words and numbers that work in the script like values that we declare

Variables are similar, but only have use in the script that they are created. Of course, you can pass on the value You can pass variables as values from script to script, but it will be unique to each script.

  • Global Variables - Can be accessed universally by all scripts
  • Variables - A value unique to the script, which can't be accessed by other scripts
  • Constants - Predefined Constants

The fun thing about coding is you can decide exactly what you want each number and word to represent.

Most of the time, you and the script interpreter will use various values interchangeably. You should treat "0" as "FALSE" or "OFF". and a "1" (or more. a non-zero value, basically) as "TRUE" and "ON"

Of course, none of this will help you to learn coding, because you must grasp "syntax". Really it is like a language, and you have to think in it. To do it well takes time and practice, and bugs and errors will always arise, even for an expert.

You should familiarise yourself with parts of the Plotscripting Dictionary.

And you should start off easy. Something like adjusting the screen or display of things. Making things move, stop and change. You should use formulas to co-ordinate the interplay of script elements.

My advice is to design something nice in the slice editor, and trying to display it on-screen. Then if you wanted, you could make it more complex and fancy.

There are undocumented features, like shortening commands.

If you like, you can create debug tools to test your scripts in CUSTOM. For example, a menu item which calls scripts. You can also use the command "show value (number)" which can take a variable you wish to see.

See Also[edit]