Making a code lock
Hi i want to create a code lock in max 5, and I want to use a counter to keep track of what number and in what order i pressed them, how can I do this?
What do you mean by "code lock?"
if by ‘code lock’ you mean a mutex/semaphore like approach, I’m just building a generic
[mutex] external that will be included in the next release of The
sadam Library. But you’ll need to wait a little bit for that (I’m hoping to launch the next release in a month, but as I’m doing it in my spare time, I can’t make a promise). The basic idea is that you’ll have many instances of the same object sharing the same name (like with coll, buffer etc.), and you’ll be able to lock/unlock them all at the same time.
Sounds like OP is just looking for a passcode.
andenn91: This isn’t secure, but will perform the way you describe:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 688.3ocyVFsaaBCEF9ZxSwQ95rHaiMP1cauFqUSDhaqW.6Hvnkrp9tOrgzRZ ApSaDaJJfhw43uyu+8gyiKBPazGDUH3qvOfffGWDD3FxNPP2uCPEoGxxSqbS Cso1XzJzx1GopKjpbgw8LR2f6SMYOHU2+yRQloM1zv0qvKgPF2dihOcEts6+ H25htdyu9BIrWz00lWG91gLG2KZiMZSp5dDbq8oOsXg8xROSlLcQgPYNsdFw AGunJgALOHfDnAgMhxJ3ntFRKEPtVuqI0f6zkfTAoUYR4RPbHsXet.jUvMHB PgPfAbHBhgjaPmBetTIxz0J2ZD1M3cZkoR9GWtPHq3q4jj3SBYonpAuTiTq5 IlLbjS+hcZJt6xyRou6ImBSTr8FI1s0vhFdSId38DburPkV3xBz2Jko4nOv1 gR76l05M6FEV1AdDv4.uQWCANE3DfiA1ZzP5HcE9RMnjDmXjPZEi3obnroMn CHFiYcut115JAnuC9dc1NqAVC6Dh8PJTVqTVSatrxXmf0Z2DLyK96AsnTOrn dqus1KxZbOyVX3HU.RlE2lK0QWyjryDgcIIexpb7QxQ5kahjVqvmoL3Hm61m lsCvm+4hkqj2Wt3sVCR3J9D505+wG5FQj1zdXK9p5iBoqHIjDJqQOntp7D7j toH7vpS7GPcVNx2qopsSb7RJbimPqvsu9hwbm4VOkGhLrHw9vG4d6syDIGCt ZpupEKWdXG+bkqRWWlcZI5dQC7RlrUTYjJW2.8liscodS5A41sBUeQqPtcut gsNFFYazWjrmCeWlXyJRVyeSuVSiji634kItOLEMuLg8gIx7xDwGlnyKSTeX JbdYJzGlXyKSLeXhOekmR70ii++hoWc37cYhRicupiF55KfQVE8bGCt1p+TH S7QES9DpXyOdZweA8eSx8B -----------end_max5_patcher-----------
its a school project where im supposed to do a code lock that have a 4 digit code, and i have to press the code in correct order to unlock, and if i press the wrong order or a wrong digit it will reset, and I’m supposed to use a counter to keep track of what order i pressed :)
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 926.3oc4Z1saaBCFF93TodOf7NMsx1Xafsi1MvtAlplHItoLQLQAms9iVu1m wDnjzfiSCArZjZik9Hfe8i+9CHub8Ui.SxdjmC79p2O8FM5EkkQZaEVFUYXD XQ7iSSiy0eQvBddd7bNX7lCJ4OJ0GfTa59LgLO4YdgYD9VXkcw5EIhTtTegv MrlsVVYFUYtzl7ok7R8A.d20bBDwKzGA78UIwo0ycxLswrI+9FDlVadYrb5C Ih4+ZEepr7BRCfJo44yJGv2RG6gBuE5cm9b920WULpFFe5rw28XCwHavzdiM X2iM9lXCIr+7aPtGavFYiem62beZlZ0bbb.seNfakCpIIVBF6AlDKl+AfBzD TXvRZDoGn5OwvO8PAEZLCC4xDJLaRsboAEi0hH3NGJsluE5b4aQFy2tAJ9DZ mkuUv+qZheOZx4opo0C4Q8XdQchCEsUNo8iF293wyQnuM0sP5gPbG3iMYsTl I.GCOPl4waq4FKr.pEwNnv5nlKnXm.eKPCF0cspnVIS3qNy4ZSDe7LsLjwRx gkAAvdHQa1Rtv07WnF6hCWRGTIW7CJiqNI5vedV7zWAGyxEtGcSL1nEl1L0F o9ySP2yiSDGmra2cNOYtnX6nzwduo3HAFWejlwwLjNAN47TB79kowO8Zm32Z CQ9Pw3DicXtASHVoePzaw3UmTd7epTxW9QgJpW0pPJ0Yp9CCiXpyCVZA7MvI vZY174o7NpLY6tPFqRhhzzXSuT0e9YtRfOxh1gvAcWkf1hollsVH4q7fpNKO xmfHc+.ibHfU8+1dKV1Go4GoXYz0lTtgnyYEzHWq7o4a2mtU0yy5CMKz0HSj E9L8BYBbtau0XKWDV+4zvbttQsIbB2Cjg5ZjgYS3TePFm6MdEXSzD9R78cQr HZJ5R7kc4aQvTzk3a5BaQrzAAS4jBRSDu60rqupEGXGbkmsd0zJUWcuKdMtA sY7bYhHVljIZ9sXa+sdHY1LtXqGYvhjYKyTM8tQIl1EsWbAVItvgQbLqDWvf Hthm1jytshrxmq3lHGJwgNj3XCi3JdnyNK4BrZac2kPessZU.wtKg9hbNr1h bXs46vZi3vZCai1zIB86cswbXsE5vZi5vZa2BRsHN3PUZnXdIGTdH7vHOrca sX3.IOqxzo+AaMHxy2N4MPsBisKWLhLfgFV36gGP4gNr7FxDK3CKugby0+vx aXZR4c4acrPCakGyskWnSKuNnnVgA0v+ADZLEzH -----------end_max5_patcher-----------
[zl] is your friend, no, with [zl stream] and [zl compare] you don’t need a counter
some example how to use it?
no, do your homework :-) (aka read the helpfile)
i´ve tried for 24 hours now, i have to hand it in soon :/
What elements do you need for the password thing?
1) Something to recognise what keys you have pressed and in which order
2) Something that compares what keys you pressed to what keys you are supposed to have pressed.
You can use a combination of [counter], [pack], [coll] and [if], which is what I assume you have been tasked to do – but there are much simpler (and more flexible) ways using objects which you might not have covered in your class yet, involving [textedit] or [zl stream] and [zl compare].
Put your mind down to use – it’s only an exercise, if you couldn’t do it on time, tell the teacher and he will help you, it’s not a crime!
If you were up front about it being a school assignment, we could have helped point you in the right direction earlier and helped described the correct approach. I can’t speak for everyone but if you think I would just hand over the code that finishes your homework for you, you are sadly mistaken. Better to ask the teacher BEFORE the deadline if he/she can be of more help.
The post above this one has a lot of helpful techniques. Basically in order to do this, you are asked to keep track of what’s been pushed. Using an object like table or pack and route will let you take the number from the counter (the order or index) and pack it to a list with the number of the key you pushed. Route could then help you separate out the numbers (according to index) and then test them.
The trigger object is also your friend, it will help you with the "reset if incorrect" part of the problem.
Forums > MaxMSP