Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Marcusqc on June 08, 2010, 09:12:07 am
-
hi,
i want to test a elaborate variable system . and to do so i have make looping freed over a key pressed expample :
$Formula: ( when
( key-pressed "Shift-C" )
( training-msg "variable show" )
)
+Name: show variable
+Repeat Count: 999
+Trigger Count: 999
+Interval: 1
+Team: 8484
$Formula: ( when
( key-pressed "Up Arrow" )
( modify-variable
@X[0]
( + @X[0] 50 )
)
)
+Name: test variable up
+Repeat Count: 1
+Trigger Count: 999
+Interval: 20
+Team: 16733525
$Formula: ( when
( key-pressed "Down Arrow" )
( modify-variable
@X[0]
( - @X[0] 50 )
)
)
+Name: test variable down
+Repeat Count: 1
+Trigger Count: 999
+Interval: 20
+Team: 2081
the problem is that the variable just keep incressed over time and i just whant it to increasse when i puch up or down.
I just whant to be able to control the variable whit a key presse for make some test
thank for your help
-
You need to use the key-reset sexp. Like this:
( when
( key-pressed "Up Arrow" )
( modify-variable
@X[0]
( + @X[0] 50 )
)
( key-reset "Up Arrow" )
)
-
is work but if i want to change the way ex: i have 200 or -200 to a positive or negative , value it get stuck and nothing change.
I run some test that i have 200 and what to drop it to 100 and i get stuck to 200, i'm not even able to go to 250 or 300.
-
I am truly sorry, but I have trouble understanding that. What's your native language?
-
lol french .. OK i will try to explain in a different way... it work .. i mean that went i press up or down the variable change ... but i can only go positive or negative, if i what to change, the variable get stuck... ex: i go up to 200 then i what to go down to 100, well the variable will get stuck to 200 what ever I'm doing( press up or down nothing change i have to reset the mission)
i hope this new syntax will help i still learn the grammar and punctuation
-
Ok, can you tell again it in French ? I'll handle the translation.
Ok, peux-tu nous la refaire en français ? Je vais me charger de la traduction.
-
sa fonctionne, je peux aller en positif ou négatif mais juste dans un sense . Example si je vais à 200 et que je veux aller à 100 (ou linverse -200 à -100) tout bloque .Je doit redémarré la mission pour changer la variable nouveau. donc en résumé si je press up je peux que augmenter ma variable car si je press down ( ou up, depend of the firts key press) tout bloque et je ne peux pas changer ma variable any more
(it's hard to tanslate in English because when i'm coding i thinks in English lol)
-
Alright, the problem seems to be that once he start to increase the variable (from 0 to 200 for example), he can only increase it and can't decrease it anymore (from 200 to 100 for example) without restarting the editor.
-
Alright, the problem seems to be that once he start to increase the variable (from 0 to 200 for example), he can only increase it and can't decrease it anymore (from 200 to 100 for example) without restarting the editor.
same thing for negative (from 0 to -200 )
-
Hardly surprising if you're using key-reset rather than key-reset-multiple.
You should also be warned that the output of the key-pressed SEXPs in loops is determined by the type of key it is. Keys like T, H and F which are assigned to "Press once for each change" style commands work differently from keys like A or Z which you hold down to continually have an effect so you may wish to swap the up and down keys to something like T, H or F for this test.
-
thank you master karajorma , T and H whit key-reset-multiple work great (up or down dose nothing so i asume there are like a or z in the coding)