Forum rules - please read before posting.

About custom menus and integer variables

Hi everyone!
These topics has been covered in other threads, but I still have a couple of questions about them.
I'm trying to create a "code lock" puzzle, the one when you type a combination in a numpad and a door opens.
I've followed the advices here in the forum, and I've managed to create a custom menu that pops up when clicking on a specific hotspot.
However, I'm currently lost on the following:

1) when customizing the menu: is it possible to enter the "size" value of the menu buttons manually, instead of using the cursor that resizes them? I've tried to click on the value (usually, doing this let you enter a value with the keyboard), but nothing happens.

2) in the menu: is it possible to make numbers appear in a box at the top of the menu? This should represent the little screen of the numpad.

3) the integer variable: from what I've read, the best way to achieve what I'm looking for is creating an Integer variable, and then manipulate its value by clicking on the custom menu buttons. However, in the ActioList, if I set the "Method" to "Increase by value" it simply adds a value (i.e.: if the variable value is 0 and I press 4, it becomes 4. If I press 3 after that, it becomes 7). And if I set the Method to Set Value, it simply changes the variable value to a new one, erasing the previous one.
I'm really scratching my head about this, for I'm trying to do a combination like "051", and I can't find a way to get the menu buttons to set the variable value to the one desired.

Thank you very much for your attention!

(oh, also: how can I view the custom menu while I'm working on it? At the beginning it appeared on the screen, but now selecting the custom menu from the menu manager doesn't make it appear onscreen anymore).

Comments

  • edited December 2018

    when customizing the menu: is it possible to enter the "size" value of the menu buttons manually, instead of using the cursor that resizes them?

    Widen the window and you'll be able to do this - it's just a quirk of the field type.

    I'm really scratching my head about this, for I'm trying to do a combination like "051"

    I think there's confusion because your safe relies on numbers whereas you want to add the values together as though they're text.

    Instead of an Integer variable to store the player's entered code, use a String. Use the Variable: Set Action to clear its value when the minigame begins, and then add on the player's chosen key to itself - much in the same way as you are already with the Integer.

    When setting a String value, you don't have an Increase by value option, but you can rely on the [var:X] token to replace its value (where "X" is the ID number of the variable). For more on this, see the Manual's "Text tokens" chapter.

    For example, let's say your String variable is 13, and you're making the Variable: Set Action for what occurs when the Player presses key 6. You'd set the New value is field to [var:13]6. This would take the String's existing value, and add "6" onto the end.

    You can then use a Variable: Check Action to determine if the String's value is "051" exactly, and react accordingly. An Integer variable would still be needed to keep track of how many buttons the player has pressed.

    is it possible to make numbers appear in a box at the top of the menu?

    Using the String variable as above, you could display this variable's value as a token in a Label element.

    how can I view the custom menu while I'm working on it?

    To be able to preview a menu, the following must be true:
    1. The scene must have an AC GameEngine prefab in it, which can be added by organising objects in the Scene Manager.
    2. The Game window must be open
    3. Preview menus in Game window? must be checked in the Menu Manager
    4. The Menu's Source field must be set to Adventure Creator

  • Hi Chris!
    Thank you very much, I've done as you said and now everything works fine!
    This is the best "customer care" forum I've ever seen!

    I've done as you said, and I even added an Integer variable to keep track of how many buttons are pressed.
    I've done as following:

    When the player clicks on a button, it runs an actionlist.
    First, it checks the value of the aforementioned Integer variable: if it's equal to 4, it reset the value of the String variable, and resets the Integer variable's value as well (so if a player tries to insert more than 4 digits, the Label on the keypad resets).
    If the Integer variable's value is not equal to 4, it adds to the String variable the chosen value, and then Increases by 1 the value of the Integer value.
    I've done this for every numeric button of the keypad.

    Is this good, or do you think I've over-complicated a simpler task?

  • edited December 2018

    The logic sounds right, so if you want to call it a day I think you could.

    In the interest of advising "best practice" though, if you're repeating the same Actions for each list, it's generally better to move the repeating Actions to a separate ActionList that each "button" ActionList runs.

    The ActionList: Run Action can be used to run a separate ActionList midway-through another.

    Going further, it's also possible to tweak ActionList fields at runtime - allowing you to repurpose them when performing a common task in slightly different ways each time. This is a feature known as ActionList parameters - a tutorial can be found here.

    You could, therefore, create a single "logic processing" ActionList that contains a String parameter to represent the clicked button. While each "button" ActionList would have its own ActionList, each would then just contain a single ActionList: Run Action that runs the "logic processing" ActionList, setting the String parameter value to it's own button value each time.

    More on parameters can be found in the Manual's "ActionList parameters" chapter.

  • Thanks Chris! I've used parameters as you said, and things are way more smooth!
    I've noticed I strange thing, though: when I customized the menu buttons, I've assigned a sound in the "Click Sound" field in each button's setting, but when I click the button the sound doesn't play. Why is that?

  • Menu sounds come from the scene's Default sound field, which you can define in the Scene Manager.

  • It worked perfectly! Thank you very much!

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.