Author Topic: testting variable whit loop  (Read 2030 times)

0 Members and 1 Guest are viewing this topic.

testting variable whit loop
hi,
i want to test a elaborate variable system . and to do so i have make looping freed over a key pressed expample :

Code: [Select]
$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




 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: testting variable whit loop
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" )
)
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 
Re: testting variable whit loop
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.

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: testting variable whit loop
I am truly sorry, but I have trouble understanding that. What's your native language?
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 
Re: testting variable whit loop
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

 

Offline MatthTheGeek

  • Captain Obvious
  • 212
  • Frenchie McFrenchface
Re: testting variable whit loop
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.
People are stupid, therefore anything popular is at best suspicious.

Mod management tools     -     Wiki stuff!     -     Help us help you

666maslo666: Releasing a finished product is not a good thing! It is a modern fad.

SpardaSon21: it seems like you exist in a permanent state of half-joking misanthropy

Axem: when you put it like that, i sound like an insane person

bigchunk1: it's not retarded it's american!
bigchunk1: ...

batwota: steele's maneuvering for the coup de gras
MatthTheGeek: you mispelled grâce
Awaesaar: grace
batwota: oh right :P
Darius: ah!
Darius: yes, i like that
MatthTheGeek: the way you just spelled it it means fat
Awaesaar: +accent I forgot how to keyboard
MatthTheGeek: or grease
Darius: the killing fat!
Axem: jabba does the coup de gras
MatthTheGeek: XD
Axem: bring me solo and a cookie

 
Re: testting variable whit loop
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)

 

Offline MatthTheGeek

  • Captain Obvious
  • 212
  • Frenchie McFrenchface
Re: testting variable whit loop
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.
People are stupid, therefore anything popular is at best suspicious.

Mod management tools     -     Wiki stuff!     -     Help us help you

666maslo666: Releasing a finished product is not a good thing! It is a modern fad.

SpardaSon21: it seems like you exist in a permanent state of half-joking misanthropy

Axem: when you put it like that, i sound like an insane person

bigchunk1: it's not retarded it's american!
bigchunk1: ...

batwota: steele's maneuvering for the coup de gras
MatthTheGeek: you mispelled grâce
Awaesaar: grace
batwota: oh right :P
Darius: ah!
Darius: yes, i like that
MatthTheGeek: the way you just spelled it it means fat
Awaesaar: +accent I forgot how to keyboard
MatthTheGeek: or grease
Darius: the killing fat!
Axem: jabba does the coup de gras
MatthTheGeek: XD
Axem: bring me solo and a cookie

 
Re: testting variable whit loop
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 )

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: testting variable whit loop
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.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

  
Re: testting variable whit loop
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)