Scripting Code Reference
by alexp
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.
- Read Player Action
- If Player Action is Follow Link:
- Set Destination based on how the author defined the link and events
- Execute Global Link Script
- Execute Link Script defined for Link
- If Player Action is Use Item:
- Set Destination based on whether an Item Effect was defined
- Execute Global Item Script
- Execute Item Script defined for Item
- If Player Action is Start Storygame, Set Destination as the Start Page of the first chapter
- Load Page determined in the Destination or stay on current page
- Execute Global Page Script
- Execute Page Script for page specified
Values / Keywords
"Start Symbol" = <Script>
"Case Sensitive" = "True"
{ULetter} = [ABCDEFGHIJKLMNOPQRSTUVWXYZ]
{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>]