Control mobile behavior and interaction.
More...
|
file | script.h |
| Functions and macros for executing in-world behavior.
|
|
file | scstruct.h |
| Structs representing behavior scripts.
|
|
|
#define | SCRIPT_GLOBALS_MAX 20 |
| Maximum number of global script flags available.
|
|
#define | SCRIPT_STACK_MAX 127 |
| Maximum value an item stored on MOBILE::script_stack.
|
|
#define | SCRIPT_ERROR_OVERFLOW -1 |
|
#define | script_trace_printf(...) |
| Alias for debug_printf() enabled when SCRIPT_TRACE is defined.
|
|
#define | SCRIPT_CB_TABLE_PROTOTYPES(idx, name, c) uint16_t script_handle_ ## name( uint16_t pc, int16_t arg, struct SCRIPT* script, struct MOBILE* actor, struct MOBILE* actee, struct TILEMAP_COORDS* tile, struct DSEKAI_STATE* state ); |
| Define prototypes for the script action callbacks.
|
|
#define | SCRIPT_CB_TABLE_CONSTS(idx, name, c) extern RES_CONST uint16_t SCRIPT_ACTION_ ## name; |
| Define extern constants that can be used e.g. in spawners.
|
|
#define | SCRIPT_TOKEN_ITER_SZ_MAX 255 |
|
|
uint16_t | script_parse_str (int8_t script_idx, char *script_txt, int16_t script_txt_sz, struct SCRIPT *script) SECTION_SCRIPT |
| Parse the given script string into an in-memory script.
|
|
uint8_t | script_init () SECTION_SCRIPT |
| Script subsystem init function that should be called in main().
|
|
void | script_shutdown () SECTION_SCRIPT |
| Script subsystem cleanup function that should be called in main().
|
|
uint16_t | script_goto_label (uint16_t pc, struct SCRIPT *script, uint16_t label_type, uint16_t label_id) |
| Find a label of the given type and return the program counter (e.g. MOBILE::script_pc) at which it exists.
|
|
Control mobile behavior and interaction.
◆ script_trace_printf
#define script_trace_printf |
( |
|
... | ) |
|
Alias for debug_printf() enabled when SCRIPT_TRACE is defined.
This was made its own alias since scripting can get rather chatty when it's enabled!
◆ SCRIPT_CB
Callback to execute a behavior action. Step in a script.
- Parameters
-
- Returns
- New value for this script's program counter (e.g. MOBILE::script_pc).
◆ script_goto_label()
uint16_t script_goto_label |
( |
uint16_t |
pc, |
|
|
struct SCRIPT * |
script, |
|
|
uint16_t |
label_type, |
|
|
uint16_t |
label_id |
|
) |
| |
Find a label of the given type and return the program counter (e.g. MOBILE::script_pc) at which it exists.
- Parameters
-
- Returns
- Index of the found label, or pc if it was not found.
◆ script_init()
Script subsystem init function that should be called in main().
- Returns
- 1 if successful or 0 otherwise.
◆ script_parse_str()
uint16_t script_parse_str |
( |
int8_t |
script_idx, |
|
|
char * |
script_txt, |
|
|
int16_t |
script_txt_sz, |
|
|
struct SCRIPT * |
script |
|
) |
| |
Parse the given script string into an in-memory script.
- Parameters
-
script_idx | Index of the script, used for debug messages. |
script_txt | The script string. |
script_txt_sz | The length of the script string. |
script | MEMORY_PTR to the SCRIPT struct to populate. |