switch dual functions

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

switch dual functions

Post 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 ?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

You obviously forgot the line

Code: Select all

$laser_trigger[local.i].isused = 1
In the first if block :wink:
Image
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post 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 .......
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post by agentmad007 »

Done i found the solution

$laser_trigger[local.i].isused = 0

wooohoooo
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Hehe well done :)
Image
Post Reply