Difference between revisions of "ScriptCompare"
From Amulets & Armor Wiki
PeeWeeRotA (Talk | contribs) (Created page with "'''Compare( [Value1], [Value2])''' The compare command checks if two values are Equal. It then sets a flag used by the next If statement. The values can be varia...") |
PeeWeeRotA (Talk | contribs) |
||
Line 1: | Line 1: | ||
'''Compare( [Value1], [Value2])''' | '''Compare( [Value1], [Value2])''' | ||
− | The compare command checks if two values are Equal. It then sets | + | The compare command checks if two values are Equal. It then sets flags used by the next [[ScriptIf|If]] statement. The values can be variables or literal values. |
+ | |||
+ | Based on the result of the comparison, all conditional flags are set. This allows future commands to view the results of the comparison. The result flags that are set by compare statements are as follows: | ||
+ | |||
+ | * Equal | ||
+ | * NotEqual | ||
+ | * LessThan | ||
+ | * NotLessThan | ||
+ | * GreaterThan | ||
+ | * NotGreaterThan | ||
+ | * LessThanOrEqual | ||
+ | * GreaterThanOrEqual | ||
+ | |||
===Arguments=== | ===Arguments=== |
Revision as of 12:37, 5 March 2014
Compare( [Value1], [Value2])
The compare command checks if two values are Equal. It then sets flags used by the next If statement. The values can be variables or literal values.
Based on the result of the comparison, all conditional flags are set. This allows future commands to view the results of the comparison. The result flags that are set by compare statements are as follows:
- Equal
- NotEqual
- LessThan
- NotLessThan
- GreaterThan
- NotGreaterThan
- LessThanOrEqual
- GreaterThanOrEqual
Arguments
Value1 - First value to compare
Value2 - Second Value to Compare
Code Example
defnum NOT_COMPLETE 0 defnum COMPLETE 1 // Variables are defined with defvar and you have 1..255 of them defvar ExitSwitch 1 defvar Block1 2 Initialize: 0: // Script run when the level is loaded Set(ExitSwitch, NOT_COMPLETE); Unblock(Block1); End() 40: // raise exit floor with switch Compare(ExitSwitch, COMPLETE); If (Equal, 99); Block(Block1); ChangeSideTexture(1373,"SWIT1U"); AreaSound(6007,-2943,-12,300,255); SlideFloorNice(114, -400, -64, 100, -1); Set(ExitSwitch, COMPLETE); Unblock(Block1); End() 99: //Escape function End()