u/UnfinitePika

I made a pin pad for a project

At first, I wanted to make it using dialog menus, but thought without an external UI would be better. Kinda like how it turned out, even though it isn't fully done yet! :)

And not so complicated as I initially thought. The individual interactions have data components and can add their value using a macro into a data storage array (and the text display using multiple "extra" entries). Then the array is checked for the values "back" or "enter" to perform those actions by deleting entries or checking if the array state matches the key sequence.

(For testing, I currently have "1,2,3" and a temporary "1,2,3,4,5,6,7,8,9" code to open the door).

But I have a question: is there a better way to compare the array to the key? Because, when checking using: {pin_pad:[1,2,3]}, it also validates if the order is wrong or there are more entries besides those.

For checking the amount of entries, I test for a potential next (pin_pad[3]), but for the order, I still check all entries individually. Even with a predicate, this isn't ideal.

If anyone knows a simple way to compare the arrays without this, feel free to tell me. Thanks! :)

u/UnfinitePika — 16 hours ago