Free Hero Mesh

Program instructions
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

(Note: This may change as the program is being written and it is currently a draft.)

In some places in a .class file, program instructions can be used. This includes in any global message block, class message block, SUBS block, Goal block, or global function definition.

The heading includes the instruction name (if in parentheses, it takes other stuff inside of the same block with parentheses; there may be brackets afterward if some other name or number is a part of it), followed by the stack effect (given in a notation like Forth).

Some headings include , and/or = after the stack diagram if it supports those prefixes optionally. In this case, , means a variable of another object (taken on the stack below the value, if writing), while = means to write instead of read (the value to write is taken below another argument if any, but above the object if any). If the heading says ,c then you can also read the value from a class (it is read-only in this case; the syntax does not change).

You can also use numbers as instructions (that push their value to the stack), either in decimal or in hexadecimal (with 0x at first), and an optional minus sign is allowed at first for negative decimal numbers. Built-in message names can also be used as instructions, pushing it to the stack..

. ( x -- )

Simply discards one value from data stack.

$[] ( -- class )

Push a class name to the stack. The class must be defined, although it does not necessarily have to be defined above where it is mentioned.

#[] ( -- message )

Push a message name to the stack. The message does not have to be declared anywhere. If there are no message handlers, sending this message to any object will just result in zero.

%[] ( -- value ) =

Read a user variable of this object. All user variables are initialized to zero and can store any value. You do not need to declare them first.

"[]" ( -- string )

Push a string to the stack. The string can include escape codes:

The string can also include directives:

The directives can optionally have a minimum field width and/or a "0" flag.

Arg1 ( -- v ) ,=

Arg2 ( -- v ) ,=

Arg3 ( -- v ) ,=

bit[] ( -- n )

A constant with exactly one bit set; replace [] with a number 0 to 31.

bnot ( in -- out )

(bit) ( -- n )

Includes a list of numbers in range 0 to 31, and the result is the number with those bits set.

Broadcast ( class msg arg1 arg2 -- count )

(Broadcast) ( msg arg1 arg2 -- count )

Class ( -- class ) ,

Destroy ( -- )

,Destroy ( obj -- )

Destroyed ( -- b ) ,

E ( -- dir )

Absolute direction constant East (0).

F ( -- dir )

Relative direction constant Forward (8).

From ( -- obj ) ,=

if ( cond -- )

Begins a conditional block. End it with then. You can also use else or el.

IsPlayer ( -- b ) ,c

LF ( -- dir )

Relative direction constant Left-forward (9).

lnot ( in -- out )

LoseLevel ( -- )

Misc1 ( -- v ) ,=

Misc2 ( -- v ) ,=

Misc3 ( -- v ) ,=

Misc4 ( -- v ) ,c=

Misc5 ( -- v ) ,c=

Misc6 ( -- v ) ,c=

Misc7 ( -- v ) ,c=

Msg ( -- msg ) ,

N ( -- dir )

Absolute direction constant North (2).

NE ( -- dir )

Absolute direction constant Northeast (1).

neg ( in -- out )

Send ( msg arg1 arg2 -- ret )

,Send ( obj msg arg1 arg2 -- ret )

Shape ( -- n ) ,c=

ShapeDir ( dir -- n ) ,c=

Temperature ( -- v ) ,c=

then ( -- )

End of a conditional block.

WinLevel ( -- )

,WinLevel ( score -- )