;core variables
#var clientversion 20
#var loadtask {updator|keys|aliases};
#var settings {rawpass|miscgags|shipgags|vehiclegags|activitygags|intromusic|vol|commandsinoutput|devmode|decchar|numpadon|AutomaticUpdate}
#var speech "disabled"
#if {%volume<100} {#pc 0 volume 100}
;Reading and writing Settings.
#File 6 {settings.set} 1
#var num 1
#ForAll @settings {
#read 6 {%i} @num;
#math num {@num + 1}};
#close 6

#ForAll @loadtask {#load @scpath/%i.set};

#alarm 3 {#load @scpath/gagcreator.set};
#alarm 4 {#load @scpath/pathupdator.set};
#alarm 5 {#load {@scpath/misc.set}};
#trigger {Welcome to: cosmic rage!} {#pc 0 stop;
#if {@intromusic = "enabled"} {
#if {@IntroPlaying = 1} {#pc @introhandle stop;#var IntroPlaying 0};
#playloop {@sppath/music/IntroMusic/DefaultIntro.wav} @vol; #var introhandle %playhandle; #var IntroPlaying 1}}  {} AnyCase
#TRIGGER {synaptic signal verified. Sleep mode disengaged. Welcome back to Cosmic Rage!} {#if {@IntroPlaying = 1} {#pc @introhandle stop; #var IntroPlaying 0}; ~@sp-register vip;~@sp-version}
#trigger {Your synaptic signal wavers for a moment, then returns with a snap!} {#if {@IntroPlaying = 1} {#pc @introhandle stop; #var IntroPlaying 0}; ~@sp-register vip;~@sp-version}
#if {@rawpass = "enabled"} {makebetter};
#alarm 10 {
#if {@activitygags = "enabled"} {#load {gags/activitygags.set}};
#if {@vehiclegags = "enabled"} {#load {gags/vehiclegags.set}};
#if {@shipgags = "enabled"} {#load {gags/shipgags.set}};
#if {@miscgags = "enabled"} {#load {gags/miscgags.set}};
};
#if {@devmode="enabled"} {#load {@scpath/dev.set}};
#if {%defined(decchar)=0 or %length(@decchar)<1} {#var decchar .};
#If {@numpadon="enabled"} {#load @scpath/numpad.set};
#if {@commandsinoutput="enabled"} {#Configure DisplayCommandsInOutput true} {#Configure DisplayCommandsInOutput false};

#trigger {$sphook &{action}:&{soundpath}:&{volume}:&{pitch}:&{pan}:&{id}} {
#if {@action = "loop"} {#playloop {@sppath/@soundpath.wav} @volume; #var @id %playhandle};
#if {@action = "playrec"} {#play {@sppath/@soundpath.wav} @volume; #var @id %playhandle};  
#if {@action = "play"} {#play {@sppath/@soundpath.wav} @volume};
#if {@pan <> "na"} {#math pan {@pan * 50}; #pc %playhandle pan @pan}; 
#if {@pitch <> "na"} {#pc %playhandle frequency @pitch} {#pc %playhandle frequency 44100};
#if {@action = "stop"} {#if {%defined(@id) = 1} {#pc %var(@id) stop}}; 
#if {@action = "adjustsound"} {#if {%defined(@id) = 1} {
  #if {@volume <> "na"} {#pc %var(@id) volume @volume}; 
  #if {@pan <> "na"} {#pc %var(@id) pan @pan}; 
  #if {@pitch <> "na"} {#pc %var(@id) frequency @pitch}
}};
#gagline all;
#if {%playhandle=0} {#SetSpeech system stop;#say {Failed to play @soundpath.};
#var faildsound {$sphook @action:@soundpath:@volume:@pitch:@pan:@id};
#if {@AutomaticUpdate="enabled"} {FetchSound @soundpath}}}
#trig {$buffer *} {#gagline all; #say %1 voiceonly}