dsekai
World engine for retrocomputers.
Loading...
Searching...
No Matches
Macros
Scripting Instructions

Overview of the mobile scripting language. More...

Collaboration diagram for Scripting Instructions:

Macros

#define SCRIPT_CB_TABLE_24(f)   f( 23, SHAKE, 'y' )
 
#define SCRIPT_CB_TABLE_23(f)   f( 23, DISABLE, 'd' ) SCRIPT_CB_TABLE_24( f )
 DISABLE: Disable Scripting Interactions with the MOBILE running this script, while still executing script instructions.
 
#define SCRIPT_CB_TABLE_22(f)   f( 22, WARP, 'w' ) SCRIPT_CB_TABLE_23( f )
 WARP: Warp to a tilemap identified by the string at the arg index in current TILEMAP::strpool.
 
#define SCRIPT_CB_TABLE_21(f)   f( 21, ANIM, 'n' ) SCRIPT_CB_TABLE_22( f )
 
#define SCRIPT_CB_TABLE_20(f)   f( 20, PUSH, 'v' ) SCRIPT_CB_TABLE_21( f )
 
#define SCRIPT_CB_TABLE_19(f)   f( 19, POP, '^' ) SCRIPT_CB_TABLE_20( f )
 
#define SCRIPT_CB_TABLE_18(f)   f( 18, EQJMP, '=' ) SCRIPT_CB_TABLE_19( f )
 EQJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is EQUAL TO the value pushed before it.
 
#define SCRIPT_CB_TABLE_17(f)   f( 17, GTJMP, '>' ) SCRIPT_CB_TABLE_18( f )
 GTJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is GREATER THAN the value pushed before it.
 
#define SCRIPT_CB_TABLE_16(f)   f( 16, LTJMP, '<' ) SCRIPT_CB_TABLE_17( f )
 LTJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is LESS THAN the value pushed before it.
 
#define SCRIPT_CB_TABLE_15(f)   f( 15, ADD, '+' ) SCRIPT_CB_TABLE_16( f )
 ADD: Add the argument to the last value pushed to the stack, and push the result back onto the stack.
 
#define SCRIPT_CB_TABLE_14(f)   f( 14, SUB, '-' ) SCRIPT_CB_TABLE_15( f )
 SUB: Subtract the argument from the last value pushed to the stack, and push the result back onto the stack.
 
#define SCRIPT_CB_TABLE_13(f)   f( 13, GIVE, 'h' ) SCRIPT_CB_TABLE_14( f )
 GIVE: Give an ITEM to DSEKAI_STATE::player based on ITEM::gid from TILEMAP::item_defs.
 
#define SCRIPT_CB_TABLE_12(f)   f( 12, TAKE, 'k' ) SCRIPT_CB_TABLE_13( f )
 TAKE: Give an ITEM to DSEKAI_STATE::player based on ITEM::gid from TILEMAP::item_defs.
 
#define SCRIPT_CB_TABLE_11(f)   f( 11, DIE, 'z' ) SCRIPT_CB_TABLE_12( f )
 DIE: Trigger death animation for MOBILE running this script and then vanish, becoming inactive.
 
#define SCRIPT_CB_TABLE_10(f)   f( 10, GGET, 'a' ) SCRIPT_CB_TABLE_11( f )
 GGET: Push a copy of a value from the global table at onto MOBILE::script_stack.
 
#define SCRIPT_CB_TABLE_9(f)   f( 9, GSET, 'b' ) SCRIPT_CB_TABLE_10( f )
 GSET: Pop a value from MOBILE::script_stack into the global table, overriding any previous value at that index.
 
#define SCRIPT_CB_TABLE_8(f)   f( 8, FACE, 'f' ) SCRIPT_CB_TABLE_9( f )
 FACE: Set the actor to face one of the Cardinal Directions.
 
#define SCRIPT_CB_TABLE_7(f)   f( 7, RETURN, 'x' ) SCRIPT_CB_TABLE_8( f )
 RETURN: Return from an interaction subroutine to the main script.
 
#define SCRIPT_CB_TABLE_6(f)   f( 6, SPEAK, 'p' ) SCRIPT_CB_TABLE_7( f )
 SPEAK: Display a dialog window with the actor's MOBILE::sprite_id and a line of text from TILEMAP::strpool.
 
#define SCRIPT_CB_TABLE_5(f)   f( 5, GOTO, 'g' ) SCRIPT_CB_TABLE_6( f )
 GOTO: Move script execution to a label defined by START.
 
#define SCRIPT_CB_TABLE_4(f)   f( 4, START, 't' ) SCRIPT_CB_TABLE_5( f )
 START: Define a label index that can be jumped to.
 
#define SCRIPT_CB_TABLE_3(f)   f( 3, SLEEP, 's' ) SCRIPT_CB_TABLE_4( f )
 SLEEP: Don't do anything for arg number of frames.
 
#define SCRIPT_CB_TABLE_2(f)   f( 2, WALK, 'u' ) SCRIPT_CB_TABLE_3( f )
 WALK: The actor walks in the direction specified on the stack.
 
#define SCRIPT_CB_TABLE_1(f)   f( 1, INTERACT,'i' ) SCRIPT_CB_TABLE_2( f )
 INTERACT: Define a Scripting Interactions callback label.
 
#define SCRIPT_CB_TABLE(f)   f( 0, NOOP, '\0' ) SCRIPT_CB_TABLE_1( f )
 NOOP: Not a valid instruction. Beginning of the script callback table, used to implement script parsing.
 

Detailed Description

Overview of the mobile scripting language.

All statements take a single numerical argument.

Args can range from 0 to SCRIPT_ARG_MAX. See scripting_args for more information on special arguments.

A script executed by a MOBILE also has access to MOBILE::script_stack, which can hold up to SCRIPT_STACK_DEPTH items.

Items on MOBILE::script_stack can range from 0 to SCRIPT_STACK_MAX in value.

Macro Definition Documentation

◆ SCRIPT_CB_TABLE_1

#define SCRIPT_CB_TABLE_1 (   f)    f( 1, INTERACT,'i' ) SCRIPT_CB_TABLE_2( f )

INTERACT: Define a Scripting Interactions callback label.

Arguments

This statement does nothing by itself, but it defines a point in the code that will be jumped to when a player interacts with the MOBILE running this SCRIPT.

Please see the section on Scripting Interactions for details on this instruction.

◆ SCRIPT_CB_TABLE_10

#define SCRIPT_CB_TABLE_10 (   f)    f( 10, GGET, 'a' ) SCRIPT_CB_TABLE_11( f )

GGET: Push a copy of a value from the global table at onto MOBILE::script_stack.

Arguments

Stack Values Pushed

Note
After being pushed, the value will still remain in its index in g_script_globals, as well.

◆ SCRIPT_CB_TABLE_11

#define SCRIPT_CB_TABLE_11 (   f)    f( 11, DIE, 'z' ) SCRIPT_CB_TABLE_12( f )

DIE: Trigger death animation for MOBILE running this script and then vanish, becoming inactive.

See Mobile MP/HP for more information on mobile death.

◆ SCRIPT_CB_TABLE_12

#define SCRIPT_CB_TABLE_12 (   f)    f( 12, TAKE, 'k' ) SCRIPT_CB_TABLE_13( f )

TAKE: Give an ITEM to DSEKAI_STATE::player based on ITEM::gid from TILEMAP::item_defs.

Arguments

Attention
: If the MOBILE executing this script is MOBILE_TYPE_SPECIAL, the item will remain in this mobile's inventory forever, wasting the limited resources of the engine. Try to only take if the item will be given back or if the mobile is disposable.

◆ SCRIPT_CB_TABLE_13

#define SCRIPT_CB_TABLE_13 (   f)    f( 13, GIVE, 'h' ) SCRIPT_CB_TABLE_14( f )

GIVE: Give an ITEM to DSEKAI_STATE::player based on ITEM::gid from TILEMAP::item_defs.

Arguments

◆ SCRIPT_CB_TABLE_14

#define SCRIPT_CB_TABLE_14 (   f)    f( 14, SUB, '-' ) SCRIPT_CB_TABLE_15( f )

SUB: Subtract the argument from the last value pushed to the stack, and push the result back onto the stack.

Arguments

  • Value to subtract.

Stack Values Popped

  • Value to subtract from.

Stack Values Pushed

  • Subtraction result.

◆ SCRIPT_CB_TABLE_15

#define SCRIPT_CB_TABLE_15 (   f)    f( 15, ADD, '+' ) SCRIPT_CB_TABLE_16( f )

ADD: Add the argument to the last value pushed to the stack, and push the result back onto the stack.

Arguments

  • Value to add.

Stack Values Popped

  • Value to add to.

Stack Values Pushed

  • Addition result.

◆ SCRIPT_CB_TABLE_16

#define SCRIPT_CB_TABLE_16 (   f)    f( 16, LTJMP, '<' ) SCRIPT_CB_TABLE_17( f )

LTJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is LESS THAN the value pushed before it.

Arguments

  • The index of the label as defined by a START instruction in the same script to jump to if the condition is TRUE.

Stack Values Pushed

Attention
If (and only if) the condition is true and the jump is performed, this instruction will automatically push the index of the next instruction that would have otherwise been executed to the MOBILE::script_stack, so that it may be returned to with RETURN and e.g. SCRIPT_ARG_STACK.

◆ SCRIPT_CB_TABLE_17

#define SCRIPT_CB_TABLE_17 (   f)    f( 17, GTJMP, '>' ) SCRIPT_CB_TABLE_18( f )

GTJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is GREATER THAN the value pushed before it.

Arguments

  • The index of the label as defined by a START instruction in the same script to jump to if the condition is TRUE.

Stack Values Pushed

Attention
If (and only if) the condition is true and the jump is performed, this instruction will automatically push the index of the next instruction that would have otherwise been executed to the MOBILE::script_stack, so that it may be returned to with RETURN and e.g. SCRIPT_ARG_STACK.

◆ SCRIPT_CB_TABLE_18

#define SCRIPT_CB_TABLE_18 (   f)    f( 18, EQJMP, '=' ) SCRIPT_CB_TABLE_19( f )

EQJMP: Move script execution to a label defined by START if the last value pushed to MOBILE::script_stack is EQUAL TO the value pushed before it.

Arguments

  • The index of the label as defined by a START instruction in the same script to jump to if the condition is TRUE.

Stack Values Pushed

Attention
If (and only if) the condition is true and the jump is performed, this instruction will automatically push the index of the next instruction that would have otherwise been executed to MOBILE::script_stack, so that it may be returned to with RETURN and e.g. SCRIPT_ARG_STACK.

◆ SCRIPT_CB_TABLE_2

#define SCRIPT_CB_TABLE_2 (   f)    f( 2, WALK, 'u' ) SCRIPT_CB_TABLE_3( f )

WALK: The actor walks in the direction specified on the stack.

Arguments

  • Number of steps to walk.

Stack Values Popped

Note
WALK will be blocked if tilemap terrain or another mobile is in the way. If blocked by a mobile, the WALK will retry until it is successful (on the assumption the mobile will move). Terrain doesn't move, so terrain blockages will just be ignored/skipped and execution will continue.

Attention
WALK is a multi-cycle instruction (to allow for the walking animation to complete. The direction will not be removed from the stack until walking is complete. Also, Scripting Interactions with a walking mobile are disabled while that mobile is in motion.
Note
If the direction popped is greater than 3, it will be divided by 4 and the remainder will be interpreted as the direction to walk.

◆ SCRIPT_CB_TABLE_22

#define SCRIPT_CB_TABLE_22 (   f)    f( 22, WARP, 'w' ) SCRIPT_CB_TABLE_23( f )

WARP: Warp to a tilemap identified by the string at the arg index in current TILEMAP::strpool.

Arguments

◆ SCRIPT_CB_TABLE_23

#define SCRIPT_CB_TABLE_23 (   f)    f( 23, DISABLE, 'd' ) SCRIPT_CB_TABLE_24( f )

DISABLE: Disable Scripting Interactions with the MOBILE running this script, while still executing script instructions.

Arguments

  • 0 To enable (disable disabled) or 1 to disable interaction.

◆ SCRIPT_CB_TABLE_3

#define SCRIPT_CB_TABLE_3 (   f)    f( 3, SLEEP, 's' ) SCRIPT_CB_TABLE_4( f )

SLEEP: Don't do anything for arg number of frames.

Arguments

  • Number of frames to sleep. This may vary in terms of precise timing by platform.

◆ SCRIPT_CB_TABLE_4

#define SCRIPT_CB_TABLE_4 (   f)    f( 4, START, 't' ) SCRIPT_CB_TABLE_5( f )

START: Define a label index that can be jumped to.

Arguments

  • Index number for this label.

Labelled indexes defined with START may be jumped to later by GOTO or JMP instructions.

◆ SCRIPT_CB_TABLE_5

#define SCRIPT_CB_TABLE_5 (   f)    f( 5, GOTO, 'g' ) SCRIPT_CB_TABLE_6( f )

GOTO: Move script execution to a label defined by START.

Arguments

  • The index of the label as defined by a START instruction in the same script to jump to.

Stack Values Pushed

Attention
This instruction will automatically push the index of the next instruction that would have otherwise been executed to the stack, so that it may be returned to with RETURN and e.g. SCRIPT_ARG_STACK.

◆ SCRIPT_CB_TABLE_6

#define SCRIPT_CB_TABLE_6 (   f)    f( 6, SPEAK, 'p' ) SCRIPT_CB_TABLE_7( f )

SPEAK: Display a dialog window with the actor's MOBILE::sprite_id and a line of text from TILEMAP::strpool.

Arguments

◆ SCRIPT_CB_TABLE_7

#define SCRIPT_CB_TABLE_7 (   f)    f( 7, RETURN, 'x' ) SCRIPT_CB_TABLE_8( f )

RETURN: Return from an interaction subroutine to the main script.

Arguments

  • The instruction index to return to.

It is common to use this with SCRIPT_ARG_STACK_I, which uses the instruction number automatically pushed to the stack on interaction, and then increments the interaction count. This is not necessary, however, and more creative uses may be devised.

Note
This instruction returns to an individual instruction index in the sequence of the script by setting MOBILE::script_pc directly, NOT by a label defined by START.

◆ SCRIPT_CB_TABLE_8

#define SCRIPT_CB_TABLE_8 (   f)    f( 8, FACE, 'f' ) SCRIPT_CB_TABLE_9( f )

FACE: Set the actor to face one of the Cardinal Directions.

Arguments

Note
If the argument supplied is greater than 3, it will be divided by 4 and the remainder will be interpreted as the direction to face.

◆ SCRIPT_CB_TABLE_9

#define SCRIPT_CB_TABLE_9 (   f)    f( 9, GSET, 'b' ) SCRIPT_CB_TABLE_10( f )

GSET: Pop a value from MOBILE::script_stack into the global table, overriding any previous value at that index.

Arguments

Stack Values Popped