Page 1 of 2

Lever, nottriggerable

Posted: Wed Aug 25, 2004 12:49 pm
by Dani
This is a continuation from another post, BUT i have the gates moving fine now, the only problem i have is that you can trigger them twice so they won't move the correct distance, how do i get this to work, here is my script now:

Code: Select all

main: 

level waittill prespawn 
$gate time 10 
$cell time 3 
level.gateopen = 0
level.cellopen = 0
end

gate_switch:
if(level.gateopen == 0){
 $gate moveup 368
 $gate waitmove
 level.gateopen = 1 
}else{
 $gate movedown 368
 $gate waitmove
 level.gateopen = 0
}
end
Please tell me how to make them nottriggerable, and please also tell me if there are any coding errors i have made.
Thanks you

Posted: Wed Aug 25, 2004 1:27 pm
by jv_map
Please, post scripting questions in the scripting forum and do not start useless polls...

As to your problem, better post the parts of your script that have to do with triggering :)

Posted: Wed Aug 25, 2004 1:44 pm
by Bjarne BZR
I think you need to add a new state: moving.
And then check to see i the gate is moving, and if so ignore the triggering.

Another way is to use

Code: Select all

$gate moveto $a_nice_waypoint
instead of telling it to move a distance. That way you can tell it to move multiple times and it will still go to the same place.

Posted: Wed Aug 25, 2004 1:49 pm
by G3mInI
Give your gate triggers targetnames. Lets say you gave the first gate trigger a targetname of gate1.

Then in code you do something like this:

Code: Select all

main: 

level waittill prespawn 
$gate time 10 
$cell time 3 
level.gateopen = 0 
level.cellopen = 0 
thread gate_switch // add this statement to execute the thread
end 

gate_switch: 
while(1) // this will run this thread in a constant loop
{
$gate1 waittill trigger // this waits until trigger is activated
$gate1 nottriggerable // and now the trigger is deactivated
if(level.gateopen == 0)
 { 
 $gate moveup 368 
 $gate waitmove 
 level.gateopen = 1 
 $gate1 triggerable // activate the trigger again
 }
else
 { 
 $gate movedown 368 
 $gate waitmove 
 level.gateopen = 0 
 $gate1 triggerable // activate the trigger again
 } 
waitframe // this is to protect the while loop from crashing - waits 1 frame
}
end

Posted: Wed Aug 25, 2004 2:03 pm
by Dani
Oh, well i can not get way pionts because i have lots of different object, and i can't get the targername thing to work.

Posted: Wed Aug 25, 2004 2:05 pm
by Dani
I am sorry, but your method with waittil trigger does not work, it just loops in a continuoes loop, which could be useful, but not here. WAT DO I DO. my map is SO close to being finished and this is the only little glitch that i have. :x :cry: :( :!: :?:

Posted: Wed Aug 25, 2004 5:40 pm
by Bjarne BZR
It shouldent really loop out of control... do you get any erors at all in the log? Set "logfile 2" before you load the map.

spawn

Posted: Wed Aug 25, 2004 5:44 pm
by tltrude
This should work. Btw, the "!" symbol means "does not".

Code: Select all

main: 

	level waittill prespawn 

	$gate time 10
	$cell time 3
	level.gateopen = 0
	level.gatemoving = 0
	level.cellopen = 0

	level waittill spawn

end

gate_switch:
 
	if((level.gateopen == 0) && (level.gatemoving != 1))
	{
		level.gatemoving = 1 
		$gate moveup 368 
		$gate waitmove 
		level.gateopen = 1
		level.gatemoving = 0
		end 
	}
	if((level.gateopen == 1) && (level.gatemoving != 1))
	{ 
		level.gatemoving = 1
		$gate movedown 368 
		$gate waitmove
		level.gateopen = 0 
		level.gatemoving = 0
	}
 
end
Would you like to add sound?

Posted: Wed Aug 25, 2004 6:03 pm
by Dani
Erm yes plz i WOULD like to add sound. But i don't know how. If you can offer me a QUICK and EASY solution then i would be happy :) thx. I will try your thing.

Posted: Wed Aug 25, 2004 6:11 pm
by Dani
tltrude you R a genious, GOD i should say, THANKS YOU. You got it to work, You got it to work, You got it to work, You got it to work, You got it to work, You got it to work, You got it to work, You got it to work, You got it to work, You got it to work, You got it to work, :D THANKS! no how about this sound?

sound

Posted: Wed Aug 25, 2004 6:24 pm
by tltrude

Code: Select all

main: 

   level waittill prespawn 

   exec global/ambient.scr mohdm7 // Background sound (wind).

   $gate time 10 
   $cell time 3 
   level.gateopen = 0 
   level.gatemoving = 0 
   level.cellopen = 0 

   level waittill spawn 

end 

gate_switch: 
  
   if((level.gateopen == 0) && (level.gatemoving != 1)) 
   { 
      level.gatemoving = 1
      $gate loopsound lighthouse_run
      $gate moveup 368 
      $gate waitmove 
      level.gateopen = 1 
      level.gatemoving = 0
      $gate stoploopsound 
      end 
   } 
   if((level.gateopen == 1) && (level.gatemoving != 1)) 
   { 
      level.gatemoving = 1
      $gate loopsound lighthouse_run
      $gate movedown 368 
      $gate waitmove 
      level.gateopen = 0 
      level.gatemoving = 0 
      $gate stoploopsound 
   } 
  
end 
Well, you wanted a quick sound! I would have to know what type gate it is for a better one. Although, there are not a lot of choices for gates that take 10 seconds to open and close. The "lighthous_run" sound is easy to use because it works in all game types--without an ubersound workaround.

I added background sound too.

Posted: Wed Aug 25, 2004 7:08 pm
by Dani
Thanks you VERY much i will try this out. It is a castle gate, one of those MASSIVE ones. I made it 10 seconds because I thought it was cool.

P.S. i also have a prison door that opens and closes, wat about sounds for this?

ok

Posted: Wed Aug 25, 2004 7:29 pm
by tltrude
Ok, change "lighthouse_run" to "m2l1_gate_open".

For the cell, use "gate_iron_open1", but change it to "playsound" and don't use the stoploopsound lines.

$Cell playsound gate_iron_open1

Posted: Wed Aug 25, 2004 9:47 pm
by Dani
thanks you a lot. One more thing, sorry to go on. But in multiplayer the sounds do not happen, why is this.

P.S. how do you find out which sounds to use, so i can do it for myself in the furture, Thanks.

Posted: Wed Aug 25, 2004 10:08 pm
by Dani
The sounds work perfectly. THANK. YOU. LOADS! Please reply my previous post?