state script_example_on
 ifvare SWITCHSCRIPTID 1 // NRSCRIPT.MAP - Starts the Rotating Gear
 {
  setvar TEMPVAR 2
  setsector[TEMPVAR].lotag 3
 
  setvar TEMPVAR 24
  setactor[TEMPVAR].x 28032
  setactor[TEMPVAR].y 33536
  setactor[TEMPVAR].z 8192
  changespritesect TEMPVAR 1

  setvar TEMPVAR 3
  setactor[TEMPVAR].x 28032
  setactor[TEMPVAR].y 33088
  setactor[TEMPVAR].z 8192
  changespritesect TEMPVAR 1

  setvar TEMPVAR 4
  setactor[TEMPVAR].x 28032
  setactor[TEMPVAR].y 33088
  setactor[TEMPVAR].z 8192
  changespritesect TEMPVAR 1
 }
ends

state script_example_off
 ifvare SWITCHSCRIPTID 1 // NRSCRIPT.MAP - Stops the Rotating Gear
 {
  setvar TEMPVAR 2
  setsector[TEMPVAR].lotag 0

  setvar TEMPVAR 24
  setactor[TEMPVAR].x 23744
  setactor[TEMPVAR].y 33504
  setactor[TEMPVAR].z 14336
  changespritesect TEMPVAR 3

  setvar TEMPVAR 3
  setactor[TEMPVAR].x 23744
  setactor[TEMPVAR].y 33504
  setactor[TEMPVAR].z 14336
  changespritesect TEMPVAR 3

  setvar TEMPVAR 4
  setactor[TEMPVAR].x 23744
  setactor[TEMPVAR].y 33504
  setactor[TEMPVAR].z 14336
  changespritesect TEMPVAR 3
 }
ends

define SCRIPTSWITCH 7445

action SCRIPTSWITCHOFF
action SCRIPTSWITCHON 1

eventloadactor SCRIPTSWITCH
 getactor[THISACTOR].lotag SWITCHSCRIPTID // The Lotag is the number of the script to play when the switch is flipped
 setactor[THISACTOR].lotag 0
 getactor[THISACTOR].hitag hitagsav // The Lotag is the number of the script to play when the switch is flipped
 setactor[THISACTOR].hitag 0
 ifvare hitagsav 0 setvar hitagsav 76
enda

useractor notenemy SCRIPTSWITCH 0
 ifvare SKILLSET? 0
 {
  action SCRIPTSWITCHOFF
  setvar SKILLSET? 1
 }
 state useswitchcheckwall
 setvar OBJECTWIDTH 32
 setvar OBJECTHEIGHT 32
 state getspritecenterz
 setvarvar KEYSCANNERZUP OBJECTCENTERZ
 subvarvar KEYSCANNERZUP OBJECTDIFF2
 setvarvar KEYSCANNERZDOWN OBJECTCENTERZ
 addvarvar KEYSCANNERZDOWN OBJECTDIFF2

 ifpdistl 1024
 {
  ifvare TEMP2 1
  {
   ifp pfacing
   {
    ifhitspace
    {
     ifcansee 
     {
      getactor[PLAYERID].z temp
      subvar temp 6144
      ifvarvarg temp KEYSCANNERZUP
      ifvarvarl temp KEYSCANNERZDOWN
      state stopsearchsounds
      ifvare com_pause 0
      { 
       ifaction SCRIPTSWITCHOFF
       {
        soundvar hitagsav
        state script_example_on
        action SCRIPTSWITCHON
       }
       else
       ifaction SCRIPTSWITCHON
       {
        soundvar hitagsav
        state script_example_off
        action SCRIPTSWITCHOFF
       }
       setvar com_pause 10
      }
     }
    }
   }
  }
 }
enda

