Difference between revisions of "Math operations"

From GTAMods Wiki
Jump to navigation Jump to search
(Created page with 'From GTA III to Vice City Stories, these games support limited math operations through the use of opcodes in the SCM file. This language is unlike most programming languages …')
(No difference)

Revision as of 09:19, 16 May 2010

From GTA III to Vice City Stories, these games support limited math operations through the use of opcodes in the SCM file. This language is unlike most programming languages so it may take a while to learn how to perform some math operations. Sanny Builder supports the use of some of the operations without the need to type in the opcode in front. On this page, these supported operations have underlines in the "Related opcodes" section.

All math operations can be done either using integers only or floats only. Otherwise the result will not be comprehensible.

Addition

1 + 4 = 5

0@ = 1  // stores the number '''1''' into the local variable 0@
0@ += 4  // adds '''4''' to the variable 0@ that stored the number '''1''' and stores the new number '''5''' into the variable 0@

0@ now equals to 4.

Related opcodes

  • 0008: global variable += integer
  • 0009: global variable += float
  • 000A: local variable += integer
  • 000B: local variable += float
  • 0058: global variable integer += global variable integer
  • 0059: global variable float += global variable float
  • 005A: local variable integer += local variable integer
  • 005B: local variable float += local variable float
  • 005C: local variable integer += global variable integer
  • 005D: local variable float += global variable float
  • 005E: global variable integer += local variable integer
  • 005F: global variable float += local variable float

Subtraction

5.5 - 8.0 = -2.5

0@ = 5.5
0@ -= 8.0

0@ now equals to -2.5.

Related opcodes

  • 000C: global variable -= integer
  • 000D: global variable -= float
  • 000E: local variable -= integer
  • 000F: local variable -= float
  • 0060: global variable integer -= global variable integer
  • 0061: global variable float -= global variable float
  • 0062: local variable integer -= local variable integer
  • 0063: local variable float -= local variable float
  • 0064: local variable integer -= global variable integer
  • 0065: local variable float -= global variable float
  • 0066: global variable integer -= local variable integer
  • 0067: global variable float -= local variable float

Multiplication

0@ * 1@ = 20, where 0@ equals 5 and 1@ equals 4

var
0@ : integer
1@: integer
end
0@ = 5
1@ = 4
1@ *= 0@

1@ now equals to 20.

Division

$var / 0@ = 6.0, where $var equals 13.8 and 1@ equals 2.3.

var
$var : float
0@: float
end
$var = 13.8
0@ = 2.3
$var /= 0@

$var now equals to 6.0.