ScriptBlock

From Amulets & Armor Wiki
Revision as of 14:06, 5 March 2014 by PeeWeeRotA (Talk | contribs) (Created page with "'''Block( [Variable])''' Prevents a block of code from being executed in parallel. The variable specified will be set to 1 the first time the block is entered and will not ru...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Block( [Variable])

Prevents a block of code from being executed in parallel. The variable specified will be set to 1 the first time the block is entered and will not run the code block again until the variable is reset to 0 with an Unblock command.

If the variable is already blocked, or set to 1 otherwise, the block will not execute. It's important to unblock this variable in script 0 while initializing other variables so that the first execution will work.

Unblock( [Variable])

Resets a variable used in a block to 0 in order to allow execution to continue.

Arguments

Variable - Variable used to track block status.

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