Scripting Code Reference

by alexp

<< All Articles | Print

Script Types

There are six types of scripts available and they are executed in the order specified below. Global scripts can be edited only on the Scripts page, all other scripts may be edited on the Scripts page or on the individual Page, Link, or Item.

  1. Read Player Action
  2. If Player Action is Follow Link:
    1. Set Destination based on how the author defined the link and events
    2. Execute Global Link Script
    3. Execute Link Script defined for Link
  3. If Player Action is Use Item:
    1. Set Destination based on whether an Item Effect was defined
    2. Execute Global Item Script
    3. Execute Item Script defined for Item
  4. If Player Action is Start Storygame, Set Destination as the Start Page of the first chapter
  5. Load Page determined in the Destination or stay on current page
  6. Execute Global Page Script
  7. Execute Page Script for page specified

Values / Keywords

 "Start Symbol" = <Script>
"Case Sensitive" = "True"

{UAlphaNumeric} = {Number} + {ULetter}
{StringChar} = {Printable} - ["] + {CR} + {LF}

Variable = '%' {ULetter} {UAlphaNumeric}*

Dest_Chap = '@C' {Number}+
Dest_Page = '@P' {Number}+
Dest_End = '@END'
Dest_Reset = '@RESET'
Dest_Save = '@SAVE'
Dest_Prev = '@PREV'
Dest_None = '@NONE'

GS_ChapterId = '$CHAPTERID'
GS_PageId = '$PAGEID'
GS_PageText = '$PAGETEXT'
GS_ItemUsed = '$ITEMUSED' {Number}+
GS_ItemState = '$ITEMSTATE' {Number}+
GS_ItemPageId = '$ITEMPAGEID' {Number}+
GS_LinkText = '$LINKTEXT' {Number}+
GS_LinkDest = '$LINKDEST' {Number}+
GS_Destination = '$DEST'

Lit_Number = {Number}+
Lit_String = '"' {StringChar}* '"'
Lit_Random = {Number}+ 'D' {Number}+

Comment Line = '#'

Script Statements

  • IF <condition> THEN <statement>
  • IF <condition> THEN
    IF <condition> THEN <statement> ELSE <statement>  

Formal Grammar

<Script> = <Statement>+

<Statement> = <Statement Block> | <Conditional Statement> | <Assignment Statement>
<Statement Block> = BEGIN <Statement>+ END
<Conditional Statement> = IF <Condition> THEN <Statement> [ELSE <Statement>]
<Assignment Statement> = {Assignable Value} := {Value}

<Condition> = [NOT] <Expression> {Conditional Operator} <Condition | Expression>

<Expression> = <Value> [{Expression Operator} <Expression>]