Disabling a switch for 2 secs ?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
Jack Ruby
General
Posts: 1443
Joined: Fri Feb 07, 2003 12:20 am
Location: london

Disabling a switch for 2 secs ?

Post by Jack Ruby »

Well I released my map but errors are being reported already :( Which is bad but good as I will be able to fix them, at least I hope I can.

I have two switches that move things, a bridge rotates up and a walkway thing moves horizontally.

The errors come when the switch gets hit repeatedly in quick succession, so as the bridge is lowering someone hits the switch before the bridge completes its movement and it either gets stuck in mid air, rotates in the completely wrong direction or strangely gets confused as to which direction it should move, its meant to lower for allies raises for axis( hope that made some sense ).

So I was thinking is there a way to disable the switch for say 2 seconds after its been hit, then it complete its movement and hopefully not get confused when its hit again ? Or maybe theres another way around it ?

Heres the script for these two switches:

//--------------------------------------------------------------
//The lock gate
//--------------------------------------------------------------
artillerystrike_switch:

if( level.bArtillerySwitchUp == 1 )
{
$lockgate moveSouth 544 // To open it
$lockgate move // or waitmove
$artillerystrike_origin speed 1.0
$artillerystrike_origin rotatexdownto 180
$artillerystrike_origin waitmove
$artillerystrike_origin playsound switchbox
level.bArtillerySwitchUp = 0
}
else
{
$lockgate moveNorth 544 // To close it
$lockgate move // or waitmove
$artillerystrike_origin rotatexupto 0
$artillerystrike_origin waitmove
level.bArtillerySwitchUp = 1
}

end

//--------------------------------------------------------------
//The Bridge
//--------------------------------------------------------------
airstrike_switch:

if( level.bAirStrikeSwitchUp == 1 )
{
$bridge rotateZdown 90
$bridge move
$airstrike_origin speed 1.0
$airstrike_origin rotatexdownto 180
$airstrike_origin waitmove
$airstrike_origin playsound switchbox
level.bAirStrikeSwitchUp = 0
}
else
{
$bridge rotateZup 90
$bridge move
$airstrike_origin rotatexupto 0
$airstrike_origin waitmove
level.bAirStrikeSwitchUp = 1
}

end
Philip II of Macedon sent a message to Sparta:
"If I win this war, you will be slaves forever."
The Spartan ephors sent back a one word reply: "If".
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

in the part where the birdge moves try
$switch remove
wait 2
$switch show

i dunno if switch was urs, i didnt read the code, but thats what u need to do.
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

nottriggerable

Post by tltrude »

Use lines like these to disable and enable the triggers.

$my_triggers_name nottriggerable
$my_triggers_name triggerable

You can hide and show entities, but they are still there (just invisible). And, if you used "switch" as a tragetname the script would crash (switch is a command word).
Tom Trude,

Image
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

doesnt "remove" actually take it out (like it isnt there)
Image
User avatar
Jack Ruby
General
Posts: 1443
Joined: Fri Feb 07, 2003 12:20 am
Location: london

Post by Jack Ruby »

Thanks guys, I am such a novice scripter I need to know exactly where to put the additional script.

Would it be possible for you to walk me through it ?
Philip II of Macedon sent a message to Sparta:
"If I win this war, you will be slaves forever."
The Spartan ephors sent back a one word reply: "If".
M&M
General
Posts: 1427
Joined: Sun Sep 14, 2003 1:03 am
Location: egypt
Contact:

Post by M&M »

i wouldnt call my self a scripter ,but shouldnt waitmove be the command ur looking 4.i mean u make the trigger wait 4 the bridge 2 move b4 being triggerable again (instead of wait #secs)
Image
vonderbakluft
Corporal
Posts: 46
Joined: Fri Aug 01, 2003 11:15 am
Location: NL
Contact:

Post by vonderbakluft »

Example:
If the trigger has the targetname mytrigger

//--------------------------------------------------------------
//The lock gate
//--------------------------------------------------------------
artillerystrike_switch:

$mytrigger nottriggerable //inmediately disable it to avoid dual use

if( level.bArtillerySwitchUp == 1 )
{
$lockgate moveSouth 544 // To open it
$lockgate move // or waitmove
$artillerystrike_origin speed 1.0
$artillerystrike_origin rotatexdownto 180
$artillerystrike_origin waitmove
$artillerystrike_origin playsound switchbox
level.bArtillerySwitchUp = 0
}
else
{
$lockgate moveNorth 544 // To close it
$lockgate move // or waitmove
$artillerystrike_origin rotatexupto 0
$artillerystrike_origin waitmove
level.bArtillerySwitchUp = 1
}


wait 2
$mytrigger triggerable //to be used again
end


Makes the trigger useable again 2 seconds after the movement is done

Von
Real mappers map in wordpad ;-)
User avatar
Jack Ruby
General
Posts: 1443
Joined: Fri Feb 07, 2003 12:20 am
Location: london

Post by Jack Ruby »

Thanks a million Von, I cant test it until I hook up with another player in the map but will let you know how it works out.

Thanks again.
Philip II of Macedon sent a message to Sparta:
"If I win this war, you will be slaves forever."
The Spartan ephors sent back a one word reply: "If".
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

M&M wrote:i wouldnt call my self a scripter ,but shouldnt waitmove be the command ur looking 4.i mean u make the trigger wait 4 the bridge 2 move b4 being triggerable again (instead of wait #secs)
whoa.
hes right.
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

waitmove will work just fine

$something remove //will delete the entity
$something show //will make an entity visible if
$something hide //has already been done
hope this helps, prob not cos it's all foreign 2 me :-/
Post Reply