Page 1 of 1

switch dual functions

Posted: Fri Nov 26, 2004 3:07 pm
by agentmad007
Hi ;)

was trying to make a switch with dual functions.When triggered the first time it disable a protection and when triggered again it enable the protection disabled before.......

waht i got in Moh radiant:

script_model

Code: Select all

targetname/laser_switch 
model/animate/alarmswitch.tik
trigger_use

Code: Select all

 targetname/laser_trigger setthread/ship_alert

Code: Select all

ship_alert:

self nottriggerable

for(local.i=1;local.i <= $laser_trigger.size;local.i++) 
{ 
   if($laser_trigger[local.i].isused !=1 ) 
   { 
	$laser_switch anim turn_on
     	$laser_switch playsound click_switch
                 iprintln "The ship is out of protection"
	
      
   } 

else



   {

	$laser_switch anim turn_off
                $laser_switch playsound click_switch	
                iprintln "Protection enable"

   }

} 

waitframe

self triggerable

end 

the first action work fine the anim is turned on , and i can see in the screen " the ship is out of protection" , but when i try a second time only the first sequence is played again .......anim dont want to turn off nor display my other message ....


can someone help plz ?

Posted: Fri Nov 26, 2004 3:28 pm
by jv_map
You obviously forgot the line

Code: Select all

$laser_trigger[local.i].isused = 1
In the first if block :wink:

Posted: Fri Nov 26, 2004 4:19 pm
by agentmad007
thx ;) it work But only twice :(

Code: Select all

ship_alert:



for(local.i=1;local.i <= $laser_trigger.size;local.i++) 
{ 
   if($laser_trigger[local.i].isused !=1 ) 
   { 
	$laser_switch anim turnon
     	$laser_switch playsound click_switch
	$laser hide	
	$axis_alert_trigger nottriggerable
	
	$axis_alert loopsound alarm

	iprintln "The ship is out of protection"

	$laser_trigger[local.i].isused = 1
	
      
   } 



else

   {

	$laser_switch anim turnoff
     $laser_switch playsound click_switch	
	$axis_alert_trigger triggerable
	$laser show
	$axis_alert stoploopsound alarm

	iprintln "Protection enable"

   }

} 

waitframe





end

i tried goto ship_alert , and the trigger fired itself like a loop .......

Posted: Fri Nov 26, 2004 4:46 pm
by agentmad007
Done i found the solution

$laser_trigger[local.i].isused = 0

wooohoooo

Posted: Sat Nov 27, 2004 8:09 am
by jv_map
Hehe well done :)