Hard Light Productions Forums
Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Light on September 04, 2011, 06:59:55 pm
-
Is there a way to make an event toggle on and off via a key-press. That is I have one event that occurs via a key-press that is the ON event and a second event that occurs via another key-press is the OFF event. I can get them to cycle one time only. What I want is for the key-presses to reset so that I can cycle it on/off as many times as I want.
As a simple test example I can make my ship change from a Hercules Mk1 into a Hercules Mk2 by pressing the 1 key. I can then make it change from a Hercules Mk2 back into a Hercules Mk1 by pressing Shift-1. However it will only do that once. What I want is for it the reset so that if I press the 1 key again if will change again and likewise when Shift-1 is pressed. The events repeating upon key-press in perpetuity.
Any idea as to how to go about doing this?
I have attached the Class Change Test.fs2 file to the post that contains my above example.
[attachment deleted by ninja]
-
the 1 key is buggy. use alt-x
you can use the same key for both. It's stupid to use two keys when you can use one. Key combinations are at a premium, especially ones that work with toggle, and don't do anything else in singleplayer.
Shift-1 is used for strafing. (Slide, like Shivan fighters).
I'd only use 1,2,3,4 and Alt-X. (and maybe D, but I bind that to either Zoom, or Press To Glide)
$Formula: ( every-time
( key-pressed "Alt-X" 0 )
( if-then-else
( = @SwapStatus[0] 0 )
( when
( true )
( change-ship-class
"GTF Hercules Mark II"
"Alpha 1"
)
( modify-variable @SwapStatus[0] 1 )
)
( when
( true )
( change-ship-class
"GTF Hercules"
"Alpha 1"
)
( modify-variable @SwapStatus[0] 0 )
)
)
( key-reset-multiple "Alt-X" )
)
+Name: SwapToggle
+Repeat Count: 1
+Interval: 1
EZ.
*based off the the cloaking toggle one (which just uses change-ship-class), minus all the extra fluff since you don't need delays/transitions :P) thanks to mjnmixael
if you're ADAMANT on using the 1 key you're going to need something like
( and
( key-pressed "1" 0 )
( > ( mission-time-msecs ) @ZWait[-1] )
)
( modify-variable
@ZWait[-1]
( + ( mission-time-msecs ) 500 )
)
instead of just the key-pressed check, in combination with this event
$Formula: ( every-time
( key-pressed "1" 0 )
( key-reset-multiple "1" )
)
+Name: ResetKey
+Repeat Count: 1
+Interval: 1
to make sure the1 key actually resets.
I am not sure about shift-1, since I actually fly ships with strafe and hence would never use it to toggle events.