Sanny Builder
In English
In English
  • Introduction
  • Credits
  • Version History
  • Language
    • Data Types
      • Constants
      • Variables
      • Arrays
    • Instructions
      • Opcodes
      • Keywords
      • Classes
      • Expressions
      • Built-in Commands
      • HEX..END
    • Control Flow
      • Labels
      • Conditions
      • Loops
      • Switch
    • Functions
    • Import/Export
    • Directives
    • Comments
  • Edit Modes
    • CustomLabels.ini
    • Code Templates
    • Enums.txt
    • Extensions
    • Opcodes List (SCM.INI)
  • Editor
    • Features
    • Options
      • General
      • Formats
      • Editor
      • Theme Editor
      • Hotkeys
      • Debugger
      • Edit modes
    • Console
    • Hotkeys
    • Opcode Search Tool
    • Command Line Interface
    • Language Service
    • SCM Debugger
  • SCM Documentation
    • GTA Limits
    • GTA III
      • Ped Types
      • Radar Icons
    • Vice City
      • Button IDs
      • Gang IDs
      • Garage IDs
      • Interiors
      • Ped Types
      • Radar Icons
      • Weapon IDs
    • San Andreas
      • Button IDs
      • Gang IDs
      • Garage IDs
      • Haircuts
      • Interiors
      • Particle Effects
      • Ped Types
      • Player Clothes
      • Player Body Parts
      • Special Actors
      • Statistics ID
      • Tattoos
      • Train Types
      • Vehicle Variations
      • Weapon IDs
      • Weather IDs
      • Zones
    • Liberty City Stories
      • Gang IDs
      • Model IDs
      • Player Clothes
      • Special Actors
      • Weapon IDs
      • Weather IDs
    • Vice City Stories
      • Gang IDs
      • Player Clothes
      • Weather IDs
  • Troubleshooting
    • Error Messages
      • 0001: INI file not found
      • 0002: Unknown array type
      • 0003: Error reading script.img
      • 0004: Unknown parameter type
      • 0005: Invalid edit mode
      • 0006: Unknown file header
      • 0007: File not found
      • 0008: Error reading opcodes list
      • 0009: Opcodes list not found
      • 0010: Unknown opcode
      • 0011: Unknown opcode
      • 0012: Incorrect jump instruction
      • 0013: Unknown directive
      • 0014: Incorrect expression
      • 0016: Script not found
      • 0017: Unknown type of variable
      • 0018: Invalid array size
      • 0019: Unknown array type
      • 0020: Variable is not declared as array
      • 0021: Incorrect variable name
      • 0022: Loop counter is not a variable
      • 0023: Unexpected instruction
      • 0024: Error reading integer number
      • 0025: Incorrect counter range
      • 0026: Error reading floating-point number
      • 0027: String is too long
      • 0028: Unterminated string
      • 0029: Invalid debug script ID
      • 0031: Invalid total number of elements
      • 0032: Invalid value in the header
      • 0033: Invalid local variable name
      • 0034: Local variable is out of range
      • 0035: Expected word
      • 0036: Local mission variable is out of range
      • 0037: Debug script not found
      • 0038: Unknown type of array
      • 0039: Invalid element definition
      • 0040: Constant name or value not found
      • 0041: Invalid mission id
      • 0042: Duplicate external script name
      • 0043: Invalid array index
      • 0044: Invalid array name
      • 0045: Invalid array syntax: variable name is missing
      • 0046: Invalid array syntax
      • 0047: Invalid array size
      • 0048: Error reading array size
      • 0049: Not enough parameters for opcode
      • 0050: Not enough parameters for command
      • 0051: Error writing script.img header
      • 0052: Error writing script.img
      • 0053: Recursive include
      • 0054: Label not found
      • 0055: Identifier not found
      • 0056: Label redeclared
      • 0057: Internal label not found
      • 0058: Invalid parameter
      • 0059: Invalid opcode definition
      • 0060: No input file
      • 0061: Empty source
      • 0062: IDE file not found
      • 0063: Mission label expected
      • 0064: Mission label not found
      • 0065: External script label not found
      • 0067: Forbidden character in external script name
      • 0068: Forbidden character in identifier
      • 0069: Forbidden character in object name
      • 0071: Incorrect number of conditions
      • 0072: Missing logical operator
      • 0073: Redundant logical operator
      • 0074: Disabled option
      • 0075: Incorrect hexadecimal value
      • 0076: Condition expected
      • 0079: Invalid parameter in Alloc command
      • 0080: Non-negative integer number expected
      • 0081: Too many actual parameters
      • 0082: Invalid syntax
      • 0083: Unknown model ID
      • 0084: Jump to offset 0
      • 0086: Invalid array index
      • 0087: Invalid variable
      • 0088: Global variable is out of range
      • 0089: Opcode not found
      • 0090: Duplicate constant
      • 0091: Not enough memory to allocate a local variable
      • 0092: Incorrect export symbol
      • 0093: Only headless scripts can export code
      • 0094: Duplicate export name
      • 0095: Incorrect import name
      • 0096: Incorrect import path
      • 0097: Too many actual parameters
      • 0098: Unknown operator
      • 0099: Left-hand side of the assignment must be a variable
      • 0100: Invalid operator
      • 0101: Variable is not a class instance
      • 0102: Switch statement needs a variable
      • 0103: Expected a switch case
      • 0104: Expected a value for the switch case
      • 0105: Expected a function argument name
      • 0106: Expected a function argument type
      • 0107: Expected function return type
      • 0108: Unsupported argument type
      • 0109: Expected variables to store function result
      • 0110: Function must return N values
      • 0111: Function not found in current scope
      • 0113: Duplicate function declaration
      • 0115: Invalid variable name. Name is reserved by another class or function
      • 0116: Invalid variable name
      • 0117: Invalid function name
      • 0118: Unexpected value to return
      • 0119: Unsupported type of argument
      • 0120: Expected calling convention type
      • 0121: Expected function's static address
      • 0122: A non-static function can't be called by name
      • 0123: A 'thiscall' function requires a pointer
      • 0124: Foreign functions can't return more than one value
      • 0125: Unexpected return type in function
      • 0126: Can't export a foreign function definition
      • 0127: Unexpected mission label in function
Powered by GitBook
On this page
  • Assignment
  • Comparison
  • Bitwise
  • Timed addition and subtraction
  • Cast assignment
  1. Language
  2. Instructions

Expressions

PreviousClassesNextBuilt-in Commands

Last updated 1 year ago

Sanny Builder supports many common operations to be written without an explicit opcode. The compiler, in this context, analyzes both the left and right sides of the expression as well as the operator between them to determine the appropriate opcode to use.

Due to the nature of the language, there are different opcodes for different types of data involved in operations. For instance, adding integer values requires a distinct opcode compared to adding two floating-point values. In most cases, the compiler is able to figure out the opcode automatically, but sometimes an upfront of variable types is needed to disambiguate the opcode.

The majority of supported operations in Sanny Builder involve just two operands: one on the left-hand side (LHS) and another on the right-hand side (RHS).

Assignment

  • LHS = RHS - an assignment operation. RHS is a numeric constant, variable, or string literal. In this context, LHS always refers to a variable.

  • LHS += RHS - an addition operation. LHS and RHS must be of the same type, either integer or float. The value of LHS gets incremented by the value of RHS.

  • LHS -= RHS - a subtraction operation

  • LHS *= RHS - a multiplication operation

  • LHS /= RHS - a division operation

The following operations require the CLEO extension ({$USE CLEO} or {$CLEO}).

  • LHS = value1 + value2 - add two integer values together and write the result in LHS

  • LHS = value1 - value2 - subtract one integer value from another and write the result in LHS

  • LHS = value1 * value2 - multiply two integer values and write the result in LHS

  • LHS = value1 / value2 - divide one integer value by another and write the result in LHS

Comparison

  • LHS == RHS - an "equal to" operation. Both sides must have the same value for the comparison to return true

  • LHS > RHS - a "greater than" operation

  • LHS >= RHS - a "greater than or equal to" operation

  • LHS < RHS - a "less than" operation

  • LHS <= RHS - a "less than or equal to" operation

  • LHS <> RHS - a "not equal" operation. Both sides must have different values for the comparison to return true

The language does not have a dedicated Boolean type. The result of each comparison only affects the current IF statement.

Bitwise

The game lacks native support for bitwise operations, making them accessible exclusively through the use of a CLEO plugin. The bitwise extension must be enabled to use the following operations ({$USE bitwise}).

Operation
Opcode
Expression

AND

0B10

0@ = 1@ & 2@

OR

0B11

0@ = 1@ | 2@

XOR

0B12

0@ = 1@ ^ 2@

NOT

0B13

0@ = ~1@

MOD

0B14

0@ = 1@ % 2@

Shift Right

0B15

0@ = 1@ >> 2@

Shift Left

0B16

0@ = 1@ << 2@

AND (compound assignment)

0B17

0@ &= 1@

OR (compound assignment)

0B18

0@ |= 1@

XOR (compound assignment)

0B19

0@ ^= 1@

NOT (mutable)

0B1A

~0@

MOD (compound assignment)

0B1B

0@ %= 1@

Shift Right (compound assignment)

0B1C

0@ >>= 1@

Shift Left (compound assignment)

0B1D

0@ <<= 1@

Timed addition and subtraction

The game natively supports timed addition and subtraction, providing FPS-independent calculations in relevant contexts. Read an article on GTAMods.com for more information.

Operation
Opcode
Expression

ADD_TIMED_VAL_TO_FLOAT_VAR

0078

$var +=@ 5.0

ADD_TIMED_VAL_TO_FLOAT_LVAR

0079

0@ +=@ 5.0

ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR

007A

$var1 +=@ $var2

ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR

007B

0@ +=@ 1@

ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR

007C

0@ +=@ $var

ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR

007D

$var +=@ 1@

SUB_TIMED_VAL_FROM_FLOAT_VAR

007E

$var -=@ 5.0

SUB_TIMED_VAL_FROM_FLOAT_LVAR

007F

0@ -=@ 5.0

SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR

0080

$var1 -=@ $var2

SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_LVAR

0081

0@ -=@ 1@

SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR

0082

0@ -=@ $var

SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR

0083

$var -=@ 1@

Cast assignment

Casting operations convert a value from one type to another. The game supports a conversion between Integer and Float types.

Operation
Opcode
Expression

CSET_VAR_INT_TO_VAR_FLOAT

008C

$i =# $f

CSET_VAR_FLOAT_TO_VAR_INT

008D

$f =# $i

CSET_LVAR_INT_TO_VAR_FLOAT

008E

0@ =# $f

CSET_LVAR_FLOAT_TO_VAR_INT

008F

1@ =# $i

CSET_VAR_INT_TO_LVAR_FLOAT

0090

$i =# 1@

CSET_VAR_FLOAT_TO_LVAR_INT

0091

$f =# 0@

CSET_LVAR_INT_TO_LVAR_FLOAT

0092

0@ =# 1@

CSET_LVAR_FLOAT_TO_LVAR_INT

0093

1@ =# 0@

The use of the operator =# requires that types of both variables are .

declaration
known