Author Topic: Routine for quick responce button?  (Read 10606 times)

0 Members and 1 Guest are viewing this topic.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Routine for quick responce button?
« on: September 15, 2011, 11:40:58 am »
How do I write a routine so that if I press the correspond button, do something and if I don't press it, do other thing?
Sig wipe!

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Routine for quick responce button?
« Reply #1 on: September 15, 2011, 11:43:27 am »
The following would work, If I understood well the question (spaces are not needed, just to see better).

Lbl (name)
   If getkey(the number)
      commands
   Else
      commands
   End
Return
« Last Edit: September 15, 2011, 11:44:30 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Routine for quick responce button?
« Reply #2 on: September 15, 2011, 11:43:58 am »
I don't code in Axe, but it might be something like this:
Code: [Select]
If getKey(*key*)
Then
<<code if key is pressed>>
Else
<<code if key isn't pressed>>
End
Again, I don't know if this will work :/

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Routine for quick responce button?
« Reply #3 on: September 15, 2011, 11:45:26 am »
I don't code in Axe, but it might be something like this:
Code: [Select]
If getKey(*key*)
Then
<<code if key is pressed>>
Else
<<code if key isn't pressed>>
End
Again, I don't know if this will work :/

This will not work, as "Then" is not an Axe token, but the idea is here, in my opinion.
« Last Edit: September 15, 2011, 11:45:32 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Routine for quick responce button?
« Reply #4 on: September 15, 2011, 11:46:23 am »
Cool, thanks! I need to learn Axe sometime XD

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Routine for quick responce button?
« Reply #5 on: September 15, 2011, 11:46:37 am »
I forgot to mention timer XP
So, I'll rephrase the question(This happens a lot to me these days)

How do I write a routine so that if I press the correspond button in certain amount of time, do something and if I don't press it, do other thing?
Sig wipe!

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Routine for quick responce button?
« Reply #6 on: September 15, 2011, 11:49:46 am »
Should work

Code: [Select]
0->A
...
If getkey(key)
A+1->A
Else
0->A
End
If A=(your_timer)
commands...
Else
other commands...
End
« Last Edit: September 15, 2011, 11:50:20 am by Fast Crash »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Routine for quick responce button?
« Reply #7 on: September 15, 2011, 11:50:48 am »
Code: [Select]
time→C                          ;example:   1000→C
!While C*getKey(*key*)
C-1→C
End
If C
   <<code if key is pressed>>
Else
   <<Code if key isn't pressed>>
End

I think this will work, again, i am not sure XD

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Routine for quick responce button?
« Reply #8 on: September 15, 2011, 11:58:13 am »
Thanks, but why do I multiply C with getKey?
can you explain it for me?
« Last Edit: September 15, 2011, 11:58:36 am by yeongJIN_COOL »
Sig wipe!

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Routine for quick responce button?
« Reply #9 on: September 15, 2011, 11:59:37 am »
If C=0, the loop will exit (if the key is still pressed).

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Routine for quick responce button?
« Reply #10 on: September 15, 2011, 12:00:19 pm »
ok. thanks for the explanation.
Sig wipe!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Routine for quick responce button?
« Reply #11 on: September 15, 2011, 12:00:38 pm »
Oops, I just realised that won't work. Let me rethink this...

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Routine for quick responce button?
« Reply #12 on: September 15, 2011, 12:01:55 pm »
lol indeed, it should be !If C in the test under the While loop.
« Last Edit: September 15, 2011, 12:02:18 pm by Fast Crash »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Routine for quick responce button?
« Reply #13 on: September 15, 2011, 12:06:08 pm »
let me see...
We want to exit the loop if the key is pressed or time reaches 0.

so just do !While C=0+getKey(*key*)

C=0+getKey(*key*) is only 0 if the key isn't pressed and C is not 0
If C is 0 or the key is pressed, the result is 1
We test for C because if it is 0, it means time ran out. So we do use If C

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Routine for quick responce button?
« Reply #14 on: September 15, 2011, 12:10:23 pm »
It will stay in the loop all the time if he doesn't press the key right ?