Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Konami Code in Harlowe?

edited January 2017 in Help! with 2.0
Is there any way I could track the player's keyboard inputs (specifically, those of the arrows, B, A, and Enter) to put a Konami Code easter egg in my game? I want it to do the following.

- Track the keyboard inputs of the player while they are in the game window and follow the sequence of keys pressed
- If the player presses "up, up, down, down, left, right, left, right, B, A, Enter" in that order, display a picture, show text reading "The Code" earned! and set variable $code to 1
- If the player presses anything other than the next key in the sequence (for example, up, up, down, down, G) reset the sequence so they have to start over

I'm assuming I'll have to use Javascript for this, because I don't see any Harlowe commands that make use of the keyboard. I'm not sure if this will be possible, seeing as how the only way to input text in Harlowe that I have found requires a lengthy and complicated block of code split into two parts. Any help with this would be greatly appreciated!

Comments

  • I was wondering the same thing. Great idea for an easter egg. I'm not sure if this is possible in Harlowe, but I don't know.
  • I'm definitely not an expert in Twine, but the closest I could come up with is using an input screen and using "wasd" instead of the arrow keys. It's definitely not an elegant solution, but it works. Here's the code I used, sorry if it isn't what you're looking for:
    (set: $code to 0)
    (set: $CodeEntry to (prompt: "What is the code?"))
    
    (if: $CodeEntry is "wwssadadba")[**The Code** Earned(set: $code to 1)]
    (else: )[Sorry, wrong code]
    
  • imnotahick wrote: »
    I'm definitely not an expert in Twine, but the closest I could come up with is using an input screen and using "wasd" instead of the arrow keys. It's definitely not an elegant solution, but it works. Here's the code I used, sorry if it isn't what you're looking for:
    (set: $code to 0)
    (set: $CodeEntry to (prompt: "What is the code?"))
    
    (if: $CodeEntry is "wwssadadba")[**The Code** Earned(set: $code to 1)]
    (else: )[Sorry, wrong code]
    

    I am 100% sure that input screens don't exist in Harlowe.
  • I am 100% sure that input screens don't exist in Harlowe.
    It is true that Harlowe does not have built in support for HTML input elements but there are a number of topics on this forum (like the Allowing users to input correct answers in HTML Text Box thread) explaining how to implement that functionality yourself.
  • imnotahick wrote: »
    I'm definitely not an expert in Twine, but the closest I could come up with is using an input screen and using "wasd" instead of the arrow keys. It's definitely not an elegant solution, but it works. Here's the code I used, sorry if it isn't what you're looking for:
    (set: $code to 0)
    (set: $CodeEntry to (prompt: "What is the code?"))
    
    (if: $CodeEntry is "wwssadadba")[**The Code** Earned(set: $code to 1)]
    (else: )[Sorry, wrong code]
    

    I am 100% sure that input screens don't exist in Harlowe.

    Yeah they do. I use them all the time in my games.
  • edited February 2017
    Deadshot wrote: »
    Yeah they do. I use them all the time in my games.
    I believe the disconnect here is hinted at in greyelf's post.

    EpicMario99 seems to be referring to a native input method which is backed by an input element, not a prompt() analogue, which is what (prompt:) happens to be.

    I suppose it's also possible that they simply didn't realize what (prompt:) does.
  • Deadshot wrote: »
    Yeah they do. I use them all the time in my games.
    EpicMario99 seems to be referring to a native input method which is backed by an input element, not a prompt() analogue, which is what (prompt:) happens to be.

    Uhhh... Sure, why not?

  • Alright, the problem here seems to be that I don't know crap about Javascript. Even with the in-depth explanations on the pages, I have no idea what any of those scripts do. I think my only hope for this would be for someone to just make the script for me so I can copy/paste it into my story, but I don't think that's happening. Oh well.

    Thanks for the help anyway, everybody!
Sign In or Register to comment.