Members | Sign In
All Forums > Mission Scripting
avatar

Is there a command for: If Player is NOT docked anywhere?

posted May 15, 2013 15:13:41 by JSpaced
I've written a bit of code where the player ship docks and receives new orders, the helm station can then press a key to "warp" to a new location.
However, I wanted, for a laugh, to put in a bit of script where if helm pressed the key while still docked, you get a fail sound and a note that the "Parking brake" is still on.

This is fine for when you ARE docked:
<event>
<if_client_key keyText="L" />
<if_docked name="Deep Space 9" />
<if_variable name="ReadytoWarp" comparator="EQUALS" value="1.0" />
<play_sound_now filename="TranswarpFail.wav" />
<warning_popup_message message="Ship is docked! External inertial dampner is set. Undock before going to warp" consoles="HE" />
</event>


But in the code to go to warp successfully, both the criteria are still met, even if you are actually docked!

<event>
<if_client_key keyText="L" />
<if_variable name="ReadytoWarp" comparator="EQUALS" value="1.0" />
<end_getting_keypresses_from consoles="H" />
<play_sound_now filename="LeaveSystem.wav" />
<set_timer name="WarpOut1" seconds="6" />
<set_variable name="ReadytoWarp" value="2.0" />
</event>


Is there a command for "Player is not docked"?
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
page   1
3 replies
avatar
BrianPletcher said May 15, 2013 15:48:50
Maybe you could set a variable in the first event (when docked) to indicate that a failure occured, then the second event would check to see if that variable had been set. You'd then want a third event which always fires on L which resets the failure variable. Pseudo code:

Event A (L pressed, Docked)
Set failureOccured = True
Failure message

Event B (L Pressed, failureOccured = False)
Success message/actions

Event B (L Pressed)
Set failureOccurred = False

That assumes that events get executed in order completely before moving on to the next true event, which seems like it should be the case.

Brian/Link
avatar
Mike_Substelny said May 15, 2013 19:00:13
This one goes back to the earliest days of mission scripting. The way to detect when the players undock is to (for example) have a timer that constantly resets to two seconds as long as they are docked. If that timer ever reaches zero it means the players have been undocked for two seconds.

See chapter 1 of "Havoc in the Hamak Sector" for an example of this.

Also, I recommend using a variable to keep your "parking brake" pop-up message from displaying more than once.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
JSpaced said May 16, 2013 12:53:59
The timer that resets as long as you're docked works brilliantly!
Hilarity now ensues if you attempt to go to "warp" while docked.
Also, because it's Key-poll activated, I don't have to worry about the "parking brake" message recurring, it just happens everytime the key is pressed.

Thank you for your help!

J
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
Login below to reply: