HeroScript

From HEWIKI
(Redirected from HSL)
Jump to: navigation, search

Welcome  ·  Tutorials  ·  The Engine  ·  HeroScript  ·  HeroBlade  ·  Art  ·  HE Setup  ·  Wiki Help

Contents

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 .hsl extension.

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.


Related links

Quick overview of the HSL language, for experienced programmers

Video Tutorials

My First HSL Script, a brief, step-by-step tutorial.


HeroScript for Programmers pt 1

HeroScript for Programmers pt 2

HeroScript for Programmers pt 3

Script Names

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 "\".

Example:

someReallyLongVariableName.someReallyLongFieldName = \

"The rest of the statement"

More Information

Other script-related topics which are worthy of their own explanations are:

HeroScript Examples

  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
  .
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox