Operator

From SimsWiki
Revision as of 01:23, 1 August 2026 by Blueybre (Talk | contribs)

Jump to: navigation, search

These are the operators available for use in the Expression primitive.

The Operator is byte 6 in the Expression Primitive and describes which mathematical operation is to be performed.

In the following explanation of what each operator does exactly, LHS stands for left-hand side, meaning the value or variable on the left side of the equation; and RHS stands for right-hand side, meaning the value or variable on the right side of the equation.

List

Hex Meaning Explanation Example
0x00 > Check if LHS is greater than RHS Literal 13 > Literal 6, Result: True
0x01 < Check if LHS is smaller than RHS Literal 13 < Literal 6, Result: False
0x02 == Check if LHS equals RHS Literal 13 == Literal 6, Result: False
0x03 += Add RHS value to LHS Literal 13 += Literal 6, Result: 19
0x04 -= Subtract RHS value from LHS Literal 13 -= Literal 6, Result: 7
0x05  := Assign RHS value to LHS Local 0 := Literal 6 -> Local 0 now carries the value 6
0x06 *= Multiply LHS by RHS Literal 13 *= Literal 6, Result: 78
0x07 /= Divide LHS by RHS. The result is truncated, meaning any fractional decimals are ignored. Literal 13 /= Literal 6, Result: 2
0x08 Flag Set? Check if the bit flag defined by RHS is set pn LHS Literal 13 Flag Set? flag# Literal 3, Result: True (13 is 00001101 in binary)
0x09 Set Flag Set the bit flag defined by RHS on LHS to 1 Assume Local 0 is currently 0, then: Local 0 Set Flag flag# Literal 3 -> Local 0 now carries the value 4 (00000100)
0x0A Clear Flag Set the bit flag defined by RHS on LHS to 0 Assume Local 0 is currently 4, then: Local 0 Clear Flag flag# Literal 3 -> Local 0 now carries the value 0 (00000000)
0x0B ++ and < Add 1 to LHS value, then compare if LHS is still smaller than RHS Assume Local 0 is currently 4, then: Local 0 ++ and < Literal 5 -> Local 0 is now 5 and the function returns False.
0x0C mod= Divide LHS by RHS but return the modulo (the remainder of the division) instead Literal 13 mod= Literal 6, Result: 1
0x0D and= The result is the value that represents which bits are set to 1 on both LHS and RHS Literal 158 and= Literal 29, Result: 28 (10011110 and= 00011101 = 00011100)
0x0E >= Check if LHS is greater than or equals RHS Literal 13 >= Literal 6, Result: True
0x0F <= Check if LHS is smaller than or equals RHS Literal 13 <= Literal 6, Result: False
0x10  != Check if LHS does not equal RHS. This returns the exact opposite result of the == operator. Literal 13 != Literal 6, Result: True
0x11 -- and > Subtract 1 from LHS value, then compare if LHS is still greater than RHS Assume Local 0 is currently 8, then: Local 0 -- and > Literal 5 -> Local 0 is now 7 and the function returns True.
0x12 or= The result is the value that represents which bits are set to 1 on either LHS and RHS Literal 158 or= Literal 29, Result: 159 (10011110 or= 00011101 = 10011111)
0x13 xor= The result is the value that represents which bits have the same state (0 or 1) on both LHS and RHS Literal 158 xor= Literal 29, Result: 124 (10011110 xor= 00011101 = 01111100)
0x14 abs(rhs) The result is the absolute value of RHS, meaning any negative numbers become positive, and positive numbers stay positive. Local 0 abs(rhs) Literal -4, Result: 4
0x15 Assign 32bit Value Set LHS to the first half of a 32-bit integer represented by RHS and RHS+1, with LHS+1 receiving the second half of the 32-bit integer. This one only has very specific use cases (e.g. to write a job's GUID into a Sim's Person Data). My person data 0x006B Assign 32bit Value Temp 0 -> My person data 0x006B is set to Temp 0, and My person data 0x006C is set to Temp 1

See Also

This article is imported from the old MTS2 wiki. It's original page, with comments, can be found at http://old_wiki.modthesims2.com/Operator

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox