Forum rules - please read before posting.

Best way to make a numerical input with AC?

I am making a 2d point-and-click puzzle game, and one puzzle i came up with needs a way for the player to input 2 numbers that set a bool variable to true if the numbers are correct.

for a more detailed explanation:
the player finds notes from a guy named Alfred and another named Ben. both notes have a number in them somewhere. for example, alfred says its been 3 days since he arrived in this place and hasn't figured out how to escape, while ben says that he had rather be at his home on 34th avenue... or something like that. the panel that they input numbers on has 2 sections labeled "A" and "B", in which they input Alfred's number, 3, and ben's number, 34, respectively.

now, the only idea i have is the obvious number pad which i havent got a clue how to even code in c# let-alone using AC action lists. can sombody point me in the right direction or give me ideas for this? thanks.

Comments

  • Welcome to the community, @BluetheFox.

    Whichever method you choose, you're going to need to make use of AC's Menu Manager, so I would recommend perhaps going through some of the Menu tutorials to become more familiar with that aspect of development.

    The simplest way to do this would be to create a new Menu with an "Input" element that allows players to enter in numbers directly via the keyboard.  A tutorial on something similar - entering in a name for the player character - can be found here.

    More complex, but still possible, would be as you described - i.e. a panel with numeric buttons in the game that the user can click on.  This could be done by creating each number as a Button element inside a new AC Menu, with each one's Click type set to Run Action List, so that you have complete control over what happens when they're clicked.

    An easy way to check for a code-sequence would be to use a simple score system, whereby you update a single integer based on what button is pressed, after checking the current score:
    1. Create a new Global Integer Variable in your Variables Manager, and name it e.g. CodeScore.
    2. When the Menu is shown (using the Menu: Change state Action), use the Variable: Set Action to reset the CodeScore value to zero, so that the player must start over.
    3. Create a new ActionList asset named "ResetCode" that has a similar such Action, along with any graphical changes you want (e.g. red light to signify the wrong code) which you can call whenever the player presses the wrong button.  You can map all number Buttons except for A3, B3 and B4 to this straight away, as they aren't in the code.
    4. Create ActionLists for A3, B3 and B4 that use Variable: Check Actions to check if the current score is correct, and either increase the Variable: Set Action if correct or run ResetCode if wrong - the "score" being how many correct key presses the player has made, so:

    score = 0, means no correct presses

    score = 1, means player has just pressed A3

    score = 2, means player has pressed A3 and then B3

    score = 3 means player has pressed A3, B3 and B4, and the panel is now unlocked

    The ActionList that then runs when B3 is clicked, then, would use a Variable: Check Action to see if the value of CodeScore is 1.  If it is, increase it to 2 - otherwise, reset it with ResetCode.

    I hope that makes sense!  It's simple to do, but a little tough to explain.

  • while i didnt actually use your solutions, it got me thinking better about how to come up with my own, and i found something that worked. :) thank you!

    for anyone with a similar problem to solve, my solution was this:

    1. create a string variable with an initial value set blank
    2. create hotspots for all my buttons
    3. create an action list that plays a click sound and resets the string variable to nothing.
    4. assign that action list to every button that isnt part of the code so that the variable is reset every time the player pushes a button that isnt part of the code
    5. for the buttons that ARE part of the code (in my case, a3,b3, and b4) create separate action lists for each button that first play the click sound, then check the string variable to see if its the name of the previous button in the sequence, then if so, set the variable to the name of this button (if not, set it to blank).
Sign In or Register to comment.

Howdy, Stranger!

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

Welcome to the official forum for Adventure Creator.