Little script question


(Flippy) #1

hey

well… im trying to make an energy barrier (ever seen starwars ep 1? the part at the end… you know what i mean :stuck_out_tongue: ) which goes up and down when you press a button.
This works like a charm so far :clap:
But now my next try… im trying to make a generator which (if blown up) will make the energy barrier go away (invisible) and when repaired will make it come back.
(Because im lazy and dont want to wait for dynamite to blow everytime i made 2 buttons for testing it…)

But now the problem… when the energybarrier is up (not moving, it’s a script_mover ofcourse) it works perfectly, going on and off like i want it.
But when it’s moving and i press the button, it doenst dissapear. I figured this might just be builtin in the engine that a script_mover while moving cannot be made invisible (setstate … invisible).
BUT when the energybarrier is all the way up when i pressed the button while going up, it stays ON instead of going off when it stops moving!
I have no idea how to fix the prob…

here is part of my script:

The moving energyfield called “door_1” (i know, it’s from the tut… -_-’ )


door_trigger1
{
	spawn
	{
		accum 5 set 1			
		wait 500			
		trigger door_trigger1 main	
	}
	trigger main
	{
		trigger door_trigger1 up
		trigger door_trigger1 down


		
	}	
	trigger up
	{
	
			accum 5 abort_if_not_equal 1	
			resetscript			
			trigger door_1 open

			accum 5 set 0			
	}
	trigger down
	{
			accum 5 abort_if_not_equal 0	
			resetscript			
			trigger door_1 close

			accum 5 set 1			
	}
}

The actual moving of the energyfield


door_1
{
	spawn
	{
	}

	trigger open
	{
		wait 500
		playsound sound/scenaric/assault/big_gate1.wav
		wait 400
		playsound sound/scenaric/assault/big_gate2.wav looping forever
		gotomarker door_pos2 35 wait
		stopsound
		playsound sound/scenaric/assault/big_gate3.wav
	}

	trigger close
	{
		wait 500
		playsound sound/scenaric/assault/big_gate1.wav
		wait 400
		playsound sound/scenaric/assault/big_gate2.wav looping forever
		gotomarker door_pos1 35 wait
		stopsound
		playsound sound/scenaric/assault/big_gate3.wav
	}
}

The “generator” script (2 buttons so far but i guess the principal involved is the same)


gen1
{
	spawn
	{
		accum 3 set 1
		wait 500
		trigger gen1 main
	}
	trigger main
	{
		trigger gen1 on
		trigger gen1 off
	}
	trigger on
	{
		accum 3 abort_if_not_equal 1
		resetscript
		wm_announce "The Main Generator has been destroyed, Energy Field off."
		setstate door_1 invisible
		accum 3 set 0
	}
	trigger off
	{
		accum 3 abort_if_not_equal 0
		resetscript
		wm_announce "The Main Generator has been constructed, Energy Field on."
		setstate door_1 default
		accum 3 set 1
	}
}

As i said, when the script_mover is not moving it works, but when it is moving it doenst.
But i hoped it would still change it’s “setstate” after it stopped moving… no luck so far…

This would ofcourse mean that destroying the generator while someone moves the script_mover will make the energyfield stay on (or off) forever (if the axis play it smart and dont construct it again lol)… which is ofcourse not what i want :moo:

damn
long post…

EDIT
i just thought of adding the “accum 5” value from above which checks if the door is ready to go open or close to the last part of the script, but it would give the same problem… it cant stop the generator being blown when the script_mover is moving… :S


(Flippy) #2

nobody of 41 people? :frowning:

is my post simply to long and boring or does actually nobody know the answer :stuck_out_tongue:

doesn’t anyone know a map which uses this kind of thing?
i was thinking of reactor first but it’s not what im looking for (what reactor does is the same as what mine does at the moment, but not what it should do… :stuck_out_tongue: )


(nUllSkillZ) #3

Sorry I have only read the first part of your post.
But you could take a look at the Battery script.
And the generator and the backdoor / magnetic doors near the gun.


(Flippy) #4

well that’s not what im looking for.
I got the energybarrier moving and all, works perfectly
but i want it to dissapear when a generator is blown, not just go down (open) (down as in dissapearing into the floor slowly)
this wont work when the barrier is moving already and the generator is blown at that time. It stays “on” even after it stopped moving instead of finishing it’s script_mover path and going off then…


(SteelRat) #5

Flippy, use the “remove” function in the script.


(Flippy) #6

remove… hm didnt know that existed

but can you bring it back after removed? cos when the generator is constructed again i need it to come back…


(psyco_mario) #7

Try alertentity to get it back


(pakalatak) #8

Why not bloking the force field “up” (hidden in the ceiling) when the generator is destroyed ? It could move very fast to simulate a power loss.
So you would not need to setstate it :smiley:


(Flippy) #9

i already tried this (but not up, just down just like you would press the button to move it down, but much faster so it looks like it dissapears)
There is one problem tho…
when the generator is destroyed, the force field moves down quickly, it’s gone. Then you press the button and up comes the force field :disgust:

EDIT
oops
i guess this can be fixed by using 2 accum values?
will try it asap :clap:


(pakalatak) #10

yep, If you keep the state of the generator (build or destroyed) in a accum, you will be able to “abort” the move procedure :smiley:


(Flippy) #11

so far no luck :frowning:
i tried the following (dont have the script atm so can’t post it):

the part in the script where the generator gets blown and build (which is untill now done by buttons to simulate it so i dont have to wait everytime for the dynamite to blow… lazy me) is where i put the accum value…
i did it like this:
in the spawn area i added “accum 2 set 0”, this being the generator ON (default at start of map)
then when you press the button accum 2 gets set to 1 (gen OFF) and when you press again to 0 (gen ON)

then in the part of the script where the energyfield is moving i added
accum 2 abort_if_not_equal 0
resetscript

like this:


door_trigger1 
{ 
   spawn 
   { 
      accum 5 set 1          
      wait 500          
      trigger door_trigger1 main    
   } 
   trigger main 
   { 
      trigger door_trigger1 up 
      trigger door_trigger1 down 


       
   }    
   trigger up 
   { 
         accum 2 abort_if_not_equal 0
        resetscript
         accum 5 abort_if_not_equal 1    
         resetscript          
         trigger door_1 open 

         accum 5 set 0          
   } 
   trigger down 
   { 
         accum 2 abort_if_not_equal 0
        resetscript
         accum 5 abort_if_not_equal 0    
         resetscript          
         trigger door_1 close 

         accum 5 set 1          
   } 
} 

so far i tried this, and also without the “resetscript” and also with abort_if_not_equal 1 values… all didnt work… i dont understand the accum thing’s fully yet i think :S
what does the “abort_if_not_equal” actually mean… it aborts the next step if the value is not equal to X? or does it abort the whole script part…?


(SteelRat) #12

It aborts the whole script section for the { and }


(pakalatak) #13

did you solve your problem ? We probably need more of your script to understand exactly what happen. One easy way to do the job is :

use accum 2 to block “normal moves” by using
accum 2 abort_if_not_equal 0 in the up & down procedure right at the begining. As Steelrat said, it with “kill” any attempt to read the code after this line. The "script does not “stop”, you can launch any other trigger.

then in the “death” of the generator you immediatly place a
accum 2 set 1
wait X
with X bigger than the time needed for the normal move. //so now we are sure that the field won’t move.
then ask for a "very fast move down (to hide it) (goto bla bla but not using the “standard” procedure).

in the “build” state of the generator, move the field up, then place a
accum 2 set 0
then launch the usual “move down” procedure.

If the goto get you into trouble when the generator blows when it’s down, you can track the state of the field with an other accum value and move it only if it’s up.

According to me, you don’t need any reset script… I fancy that you ask for a “wait Y” when the field reaches an extreme position ?