Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: HLD_Prophecy on October 19, 2016, 09:45:34 am

Title: How to set up a key prompt?
Post by: HLD_Prophecy on October 19, 2016, 09:45:34 am
Hey all!

So I'm trying to figure out how to set up a Y/N type key press prompt for the player. Subtitle Text will display prompting the player to press Y or N, and whichever key is pressed will determine the next chain of events (so if the event "key pressed is N" is true, then a certain subtitle text will display and a ship will warp in a few seconds later, but if the event "key pressed is Y" is true, then a different subtitle text will display and the ship will warp in right away.

Anyone know how this works?

Thanks!
Title: Re: How to set up a key prompt?
Post by: mjn.mixael on October 19, 2016, 12:06:47 pm
I'm at work, so I'm doing this off the cuff without reference to FRED, but it will look something like this.

Code: [Select]
SomeEvent
-When
--(some trigger, doesn't matter.. just whatever you want to start the keypress event)
--show-subtitle-text [your text (Press Y for this N for that)]
--key-reset (This causes FSO to see those keys as unpressed from this moment until they are pressed)
---[the keys you want to use for yes/no]
SomeEvent 2 (also use this event with is-event-true-delay for the ship arrival trigger)
-When
--And (so that this event only triggers after the event above)
---is-event-true-delay[SomeEvent]
---key-pressed [whatever key for yes]
--clear-subtitles(to clear the instruction subtitle)
--show-subtitle-text
SomeEvent 3 (also use this event with is-event-true-delay for the ship arrival trigger with a delay)
-When
--And
---is-event-true-delay[SomeEvent]
---key-pressed [whatever key for no]
--clear-subtitles(to clear the instruction subtitle)
--show-subtitle-text

Now if the ship to warp in is the same ship for both yes and no with the delay being different, then you can add something like this.
Code: [Select]
SomeEvent 4 (use THIS as your ship arrival cue)
-When
--or
---is-event-true-delay(SomeEvent 2)
---is-event-true-delay(SomeEvent 3)
--Do-nothing

Then add set-arrival-info to SomeEvent 2 & 3 to modify the arrival delay.
Title: Re: How to set up a key prompt?
Post by: HLD_Prophecy on October 20, 2016, 08:59:47 am
Awesome, thanks! I'd tried it before and came out with pretty much this, but I didn't have the key-reset.

I will try it when I've got the time and reply again if it doesn't work, but I can't see why it shouldn't. :)
Title: Re: How to set up a key prompt?
Post by: HLD_Prophecy on October 20, 2016, 07:42:30 pm
Okay, I've tried it - pressing Y works perfectly! But pressing N does nothing. The events are set up right... can you help me solve this?