Forum rules - please read before posting.

How to make a password to open a container/chest

I am going to show how to put a password to open a container, like a treasure chest or a safe.

1 - first follow the tutorial https://adventurecreator.org/tutorials/letting-player-enter-their-name.
2 - stop in the part he says: ''The Slot # field can be ignored, since the Input box is not a multi-slot element.''
3 - now that you have your menu and string variable, create a container and a hotspot.
In my example, my menu is called Gavetaroxa, my Input is empty and my button is callled OK. Also my variable is a string type, the label is ''senhaescrita'' and the value is ''manu''. You must alter it as you wish, the value will be the password.
4 - Inside the menu Gavetaroxa, in the OK button, create an actionlist inside the ''actionlist to run''. Name as you wish.
5 - Open the actionlist.
The first action is: variable/set/global/senhaescrita(label of your variable)/Set as menu element/Gavetaroxa (name of your menu)/ Input/0/skip
the second action is: variable/check/global/senhaescrita/entered value/equal to/manu (my password and variable value)/case sensitive checked
now put two other actionlists, one if the condition is met, and other if is not.
For the one condition is met, put: container/dont ckeck affect active container/open/ choose the container you want to open/don't check open in set element.
If condition is not met, put: dialogue/play speech/don't check player line/ dont choose speaker/ put ''wrong answer!'' (or whatever you want to say, if the password is wrong)/ dont check play in background/no wait time/ after running stop.
6 - after that, you can put this action list inside the button OK.
7 - in the hotspot you created, go to inspector and create a use interaction, create a actionlist. Inside that put: Menu/change state/turn on menu/Gavetaroxa(name of your menu)/after running stop.
8 - go to play mode and test your password, it has to be the value of the variable string.

Things you should know:
My interaction method is : choose hotspot then interaction. I don't know if it makes a difference.
Writing in capital block matters, putting space between words also matters, so check twice the names you put, and check in the console window if everything is right, in play mode.
if your container doesn't work properly, go to menu and in the asset file change for demo manager, copy the container menu, put it back your own menu and replace your container menu for his. I dont know why, but mine container worked only this way.

I hope this is useful for someone, but I am a noob in unity/AC, also english is not my native language, so excuse any mistakes.

https://drive.google.com/file/d/1JB09FE4ukQ0a7RlLE4p7p8GDdFdIH38T/view?usp=sharing

Comments

  • edited April 2021

    P.S. After open the menu it didn't close alone or clicking off (when the answer is wrong), so I went back to the actionlist of the Ok button, and I add a Menu/change state/turn off menu/Gaveta roxa(menu name)/stop, in the end of the actionlist. I also change the wait time offset to 0.06, so the player can read the ''wrong answer'' message, and then it disappear. It worked like a charm!

  • part 2 of this saga

    I had like 20 chests/drawers and didn't feel like making 20 menus, so to use only one menu and one actionlist I had to use parameters.
    It goes like this:

    Create a actionlist that is gonna be the ''standard'' one, just like the one we already did but with parameters on the variable, container and hostpot (only if you want to disable the chest afterwards, if not, then delete the action in the stardard list and don't make the hotspot parameters)

    https://imgur.com/DZoJNHC

    parameters:
    https://imgur.com/0mObqwu

    On the hotspot create a interaction:
    https://imgur.com/C0nTQe5

    the button on the menu doesn't support string variable, you will need a 'bridge' to open the ''standard list'', so create a new actionlist:
    Action list /source asset file/ (put you standard list on the space ) Run mode only/ run from start check/ wait until finish check.

    That's all. Now you can make lots of chests and only use one menu.

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.