Difference between revisions of "ScriptBlock"

From Amulets & Armor Wiki
Jump to: navigation, search
 
Line 49: Line 49:
 
End()
 
End()
 
</nowiki>
 
</nowiki>
 +
 +
 +
----
 +
Back to [[Scripting]] Main Page

Latest revision as of 21:26, 17 October 2016

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.

Note: Use the Block and Unblock command in situations where the same code can be run multiple times.

  • If a Delay command is used, the code will not finish executing before the player has a chance to activate it again.
  • Scripts 0-200 run for all players in multiplayer. It's possible for two players to hit a switch or activate a floor plate close enough to cause parallel scripts.
  • Scripts commands that call another script, such as If, Gosub, and SlideFloorNice, can call the same script recursively, within loops, or as parts of other scripts that load the same script into scope multiple times.

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



Back to Scripting Main Page