ScriptGosub

From Amulets & Armor Wiki
Jump to: navigation, search

Gosub( [ScriptNum] )

Executes the specified script, and then continue executing the current script.

Note: Unlike Goto and If commands, Gosub finishes executing the current script block. This happens because the specified script is added to the scope and then returns control to the existing script, instead of changing control.

Arguments

ScriptNum - Script to execute

Example

18:     // druid room switch 3
   Compare(TrapComplete, COMPLETE);
   If(Equal, 99);
   Block(Block6);
   Set(TrapDoor, ACTIVATED);
   ChangeSideTexture(1592,"SWIT1U");
   AreaSound(6007,173,1144,300,255);
   Delay(300);
   Gosub(23);
   Delay(160);
   ChangeSideTexture(1592,"SWIT1D");
   AreaSound(6007,173,1144,300,255);
   Gosub(20);
   Unblock(Block6);
   End();

20:     // missiles in trap
   GenerateMissile(4015, 39, 866, 45, -24, 866, 45, 50);
   GenerateMissile(4015, 39, 986, 45, -24, 986, 45, 50);
   End();

23:    // open last door
   Block(Block9);
   SlideCeilingNice(168,0,120,50,-1);
   AreaSound(5003, 2, 824, 500, 255);
   Delay(90);
   SlideCeilingNice(168,0,0,50,-1);
   AreaSound(5003, 2, 824, 500, 255);
   Delay(70);
   Unblock(Block9);
   End();

99:     // all purpose ender
   End();