Difference between revisions of "ScriptCompare"

From Amulets & Armor Wiki
Jump to: navigation, search
 
Line 1: Line 1:
'''Compare( [Value1], [Value2])'''
+
'''Compare( [Value1], [Value2] )'''
  
 
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.
 
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.

Latest revision as of 20:47, 2 December 2016

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

Any condition that is true for the comparison is set to 1 for TRUE, and any condition that is false for the comparison is set to 0 for FALSE.


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()



Back to Scripting Main Page