HeroScript, or HSL, for HeroScript Language, is the underlying scripting language used by game designers to build the game itself.
A script is a named set of functions and/or methods, referenced either by the field
mainScript on nodes, or via a class on the node which calls a similarly named class methods script. When something happens to a node, the appropriate function or method is called in the script on that node. Scripts are contained in a file with the
When writing a script, it will generally be necessary to use a combination of commands, HSL-written functions, and built-in functions. The main difference between these is one of syntax. HSL and built-in functions use the format
functionname(arg1, arg2) whereas commands usually use the format
commandname arg1 arg2 arg3. Please see the bottom of this page for specific examples.
- Quick overview of the HSL language, for experienced programmers
- Commands Syntax Reference
- Quick Ref to the various HeroScript commands
- General information about how to define and use functions in scripts
- Function Index
- Signatures and documentation about existing functions
- Expressions and Data References
- How to subtract/multiply/divide/etc. This page also contains a list of System Variables
- Data Types
- Definitions for the types of data that can be stored in fields
- Data Storage Options
- Many different methods that a script can save information on the server
- Character Behave Commands
- The tie-ins to the character animation system
- Asynchronous Programming
- Code Snippets
- Pre-written snippets of code to help you accomplish every task (well ok maybe not every, but lots...erm some...well maybe a couple)
- Do's and Don'ts of Scripting
- Information on standards and best practices
- Invoking scripts
- The different ways that a script can be called or triggered
Script names are strings like "GetString" or "orc27" or "attack"
A script name can also be built as part of a string. For example, to call the shared function
foo() which exists in script
orc27.hsl, all of the following would work:
// orc27:foo() "orc27":foo() aVariable = 27 "orc"+aVariable:foo() mainScript as scriptref mainScript = "orc"+aVariable mainScript:foo() ScriptReferenceVariable as scriptref = "orc"+27 ScriptReferenceVariable:foo()
Line Continuation Note
It is possible to continue a long line in HeroScript with the continuation character "\".
"The rest of the statement"
Other script-related topics which are worthy of their own explanations are:
- Lists - Collections of objects, or even collections of lists (or collections of lists of lists...)
- TIMER - A description of how the various timer nodes work
- Paths - A description of how to manipulate travel paths
str as string str = "BigWord" if (str.length > 4) println("This string is more than 4 characters long.") else println("This string is less than 4 characters long.") .
// the old way v as vector3 v.x = 1.0 v.y = 2.0 v.z = 3.0 printV3(v) // or as of version 1.23 var v2=(1.0, 2.0, 3.0)
n as noderef n = 5 if (n = 0) // 5 wasn't a valid node id .