Author Topic: How to make stuff do by pressing some buttons in quick order  (Read 4032 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
Like, pressing [2nd], and then [ALPHA], and then [MODE] quickly, but not at the same time.
I can't think of an routine for it...
Sig wipe!

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How to make stuff do by pressing some buttons in quick order
« Reply #1 on: March 18, 2011, 08:13:10 pm »
Code: (Axe) [Select]
:0→K        . No keys pressed yet
:Lbl LP        . Loop until the three keys are pressed in order
:If getKey(54)        . If 2ND is pressed
:→K        . The first key's been pressed
:ElseIf getKey(48)        . Otherwise, if ALPHA is pressed
:!If K-1        . If the first key's been pressed
:+2→K        . Two keys have been pressed
:End        . End the If
:ElseIf getKey(55)        . Otherwise, if MODE is pressed
:!If K-2        . If the first two keys have already been pressed
:Goto LE        . We're done
:End        . End the If
:End        . End the testing
:Goto LP        . Go back to main loop
:Lbl LE        . We're done!
« Last Edit: March 18, 2011, 08:17:50 pm by Deep Thought »




Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: How to make stuff do by pressing some buttons in quick order
« Reply #2 on: March 18, 2011, 08:14:34 pm »
Code: [Select]
!If getKey(1)
Goto END:End
Pause 50
!If getKey(2)
Goto END:End
Pause 50
...
Lbl END
Disp "EPIC FAILURE"
.CLEAR RAM
Asm(ABCDEF)

Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: How to make stuff do by pressing some buttons in quick order
« Reply #3 on: March 18, 2011, 08:14:34 pm »
You could start a timer on [2nd], then checking said timer on [MODE] if you were quick enough.

(Uhh did I got ninja'd?)
« Last Edit: March 18, 2011, 08:15:29 pm by juju2143 »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: How to make stuff do by pressing some buttons in quick order
« Reply #4 on: March 18, 2011, 08:15:55 pm »
Code: (Axe) [Select]
:0→K
:Lbl LP
:If getKey(54)
:→K
:ElseIf getKey(48)
:!If K-1
:+2→K
:End
:ElseIf getKey(55)
:!If K-2
:Goto LE
:End
:End
:Goto LP
:Lbl LE
What does ->K itself do?
*yay. 500th post
« Last Edit: March 18, 2011, 08:16:12 pm by yeongJIN_COOL »
Sig wipe!

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How to make stuff do by pressing some buttons in quick order
« Reply #5 on: March 18, 2011, 08:16:58 pm »
Code: (Axe) [Select]
:0→K
:Lbl LP
:If getKey(54)
:→K
:ElseIf getKey(48)
:!If K-1
:+2→K
:End
:ElseIf getKey(55)
:!If K-2
:Goto LE
:End
:End
:Goto LP
:Lbl LE
What does ->K itself do?
*yay. 500th post

Whatever was left in HL is stored to K. In this case, after If getKey(54), HL holds 1 if it's true. So you can just store that straight to K to save a couple of bytes.

After If getKey(48), it's the same, but you add 1 so you store a 2 to HL.
« Last Edit: March 18, 2011, 08:18:32 pm by Deep Thought »




Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: How to make stuff do by pressing some buttons in quick order
« Reply #6 on: March 18, 2011, 08:17:56 pm »
wait you could do that?  :o
I just started to learn Axe.
Sig wipe!

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How to make stuff do by pressing some buttons in quick order
« Reply #7 on: March 18, 2011, 08:19:35 pm »
wait you could do that?  :o
I just started to learn Axe.

Yep, Axe is great for weird syntax :D If it's weird, chances are it's optimized.

Since you're new to Axe, though, guess I should do a more basic example... I edited my post with comments, anyway.




Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: How to make stuff do by pressing some buttons in quick order
« Reply #8 on: March 18, 2011, 08:33:39 pm »
Even though im new to axe, i can see what binder's code do... O.O
Sig wipe!

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: How to make stuff do by pressing some buttons in quick order
« Reply #9 on: March 18, 2011, 08:42:06 pm »
It doesn't let you do anything else while waiting for the key, though, and you must hold down the keys long enough for it to work.

EDIT: Just realized something: My code actually does allow the user to press all three buttons at once. Here:

Code: (Axe) [Select]
:0→K        . No keys pressed yet
:Lbl LP        . Loop until the three keys are pressed in order
:While getKey(54)        . If 2ND is pressed, don't register any other keys
:→K        . The first key's been pressed
:End        . End this loop
:While getKey(48)        . Otherwise, if ALPHA is pressed, still don't register other keys
:!If K-1        . If the first key's been pressed
:+2→K        . Two keys have been pressed
:End        . End the If
:End        . End that loop
:While getKey(55)        . Otherwise, if MODE is pressed (you get the drift)
:!If K-2        . If the first two keys have already been pressed
:Goto LE        . We're done
:End        . End the If
:End        . End the final loop
:Goto LP        . Go back to main loop
:Lbl LE        . We're done!

Should work better. It pauses while you're holding down the keys, though.
« Last Edit: March 18, 2011, 08:46:52 pm by Deep Thought »