SSBScript
SSBScript is a custom programming language, created by Capypara, used to edit the game's SSB files. It is the lower-level counterpart to ExplorerScript, meaning that it provides a more raw representation of a script's code. An SSBScript file would only consist of scripting opcodes without many programming abstractions usable in ExplorerScript. This includes, but is not limited to:
- Loops
- Conditional statements
- Simple entity targeting (e.g., with-statements)
SkyTemple does not currently support a way to toggle between ExplorerScript and SSBScript in the script editor.
SSBScript Decompilation Fallback
Starting with SkyTemple 1.8.0, some scripts that would fail to decompile to ExplorerScript would instead fall back to an SSBScript representation. All scripts decompiled using this feature begin with the following comment block:
//?: is-ssb-script: true
// WARNING:
// Failed to normally decompile this script. This is either because of a bug
// in the decompiler or because this script was not valid.
//
// The following is a fallback decompilation as SsbScript that may not be as easy to read.
//
// IMPORTANT: This is now SsbScript instead of ExplorerScript. If you remove the very first
// line (//?: is-ssb-script: true), then the compiler will try to compile this file
// as ExplorerScript again.
// Before this is possible you will need to re-write this file to be valid ExplorerScript.
While reasons for a failed ExplorerScript decompilation may vary, the most common cause is control flow. It is strongly recommended to always keep backups of your ExplorerScript source files (present within the SCRIPT directory of the ROM's associated .nds.skytemple directory).
Comparison to ExplorerScript
SSBScript lacks many typical programmatic abstractions of ExplorerScript due to solely relying on SSB opcodes. As such, while SSBScript is very likely more difficult to read than ExplorerScript, it offers a more accurate view of the underlying opcodes a script contains, including certain opcodes you may not otherwise see in ExplorerScript.
Below are a few examples of equivalent ExplorerScript and SSBScript code.
| ExplorerScript | SSBScript |
|---|---|
$CONDITION = 11621;
$CONDITION -= 403;
$CONDITION /= 8;
|
flag_Set($CONDITION, 11621);
flag_CalcValue($CONDITION, 1, 403);
flag_CalcValue($CONDITION, 4, 8);
|
switch($CONDITION) {
case & 0b1:
$CONDITION *= 11;
break;
case & 0b10:
$CONDITION *= 22;
break;
case & 0b100:
$CONDITION *= 33;
break;
}
|
Switch($CONDITION);
CaseValue(8, 1, @label_1);
CaseValue(8, 2, @label_2);
CaseValue(8, 4, @label_3);
Jump(@label_4);
@label_1;
flag_CalcValue($CONDITION, 3, 11);
Jump(@label_4);
@label_2;
flag_CalcValue($CONDITION, 3, 22);
Jump(@label_4);
@label_3;
flag_CalcValue($CONDITION, 3, 33);
@label_4;
|
Turn2Direction<actor ACTOR_NPC_HERO_FIRST>(4, 10, DIR_UPRIGHT);
WaitExecuteLives(ACTOR_NPC_HERO_FIRST);
MovePositionMark<performer 0>(1, Position<'pos', 58, 1>);
WaitExecutePerformer(0);
|
lives(ACTOR_NPC_HERO_FIRST);
Turn2Direction(4, 10, DIR_UPRIGHT);
WaitExecuteLives(ACTOR_NPC_HERO_FIRST);
performer(0);
MovePositionMark(1, Position<'pos', 58, 1>);
WaitExecutePerformer(0);
|