This guide will go over how to make a 4 digit code system for doors or aome random stuff. It will be randomized every time the game starts, to make it harder, and an input for it (with counters and buttons, you can do triggers too).
""Credits""
This guide by @Dragons_Bane came first (idk if I need to do that but when i post one people keep saying this):System
This is how it should look like when done (not exactly like this but it should have these things):Things Needed:
- 8 Properties (yes its alot but you need em’, it also depends on how many digits your code is, digits*2 is the amount of properties you need.)
- 4 Counters
- 2 Triggers (6 if you use them for inputting the code)
- 6 Buttons (2 if you use triggers for the code)
- 5 Wire Repeaters
- 1 Popup
- 1 Overlay
- 1 Lifecycle
- 1 Repeater
- 3 Block Codes
Code Generator
You will need to place 4 Properties, I reccomend to name them #1, #2, #3, etc. You can go up to like 8 digits, but it will be hard to make the block for checking if the code inputted is equal to one was generated. Set property type to number.
Then, place a Lifecycle, make sure it is set to Game start.
Place a Trigger, go to “Blocks”, and make a block for “When triggered”. In the block, make this script:
Wire the life cycle to the trigger with “When event occurs” to “Trigger”
You can make an overlay to display what the code is, place an overlay, go to blocks, make a block with channel, name it what you want and make block like this:
The amount of it will go up like in the trigger. They should also be in order so that it won’t be like (#4#2#1#3, it will mess up how you see it and you will have to guess the order).
For it to update, place a repeater, set its interval to 0.5, and stop strategy to “After recieveing on channel”, set the channel for “When task occurs” to the on e you made in the overlay. Wire the lifecycle to it and make it start the repeater.
When you play the game, it should show a number in the corner you set the overlay to be in.
Code Input
Place a button, a counter, and a wire repeater. This will be how the code will be inputted.
Go to the counter and set it’s target to 10. Then wire it all like this:
Button (or a trigger)>Counter: Button Pressed > Increment Counter;
Counter>Wire Repeater: Target Value Reached > Repeat Wire Pulse;
Wire Repeater>Counter: Wire “Pulsed” (or what idk) > Reset Counter.
What this does is when the counter goes up to 10, it will reset to 0.
Make a property named something like “Input#1”, go to the counter, “Property” tba, and set set the property to change to the property you just made.
Repeat this the amount of digits you have, changing the property to #2, 3, 4, etc.
Code Check
You will need a button (or a trigger) and a trigger. Wire the button (or you can use the trigger individually with player collision on). In the trigger, make a script something like this:
If Get Property ("#Digit") = Get Property ("Input#Digit")
and (repeat this amount of digits increasing the digit of the = check
Then broadcast on channel (what you want)
I couldn’t make a screenshot for since the script is too “wide”, I don’t know if you can make out something from this:
And you’re done. The channel can be for like opening a door, or give an item.
- 0/10
- 1/10
- 2/10
- 3/10
- 4/10
- 5/10
- 6/10
- 7/10
- 8/10
- 9/10
- 10/10
- 11/10