Forums > MaxMSP

Making a code lock

October 10, 2011 | 3:14 pm

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?


October 10, 2011 | 5:42 pm

What do you mean by "code lock?"


October 10, 2011 | 6:32 pm

Hi,

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.

HTH,
Ádám


October 10, 2011 | 7:28 pm

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. –

October 11, 2011 | 6:44 am

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 :)


October 11, 2011 | 6:47 am
– Pasted Max Patch, click to expand. –

October 11, 2011 | 7:18 am

[zl] is your friend, no, with [zl stream] and [zl compare] you don’t need a counter


October 11, 2011 | 7:27 am

some example how to use it?


October 11, 2011 | 7:30 am

no, do your homework :-) (aka read the helpfile)


October 11, 2011 | 7:32 am

i´ve tried for 24 hours now, i have to hand it in soon :/


October 11, 2011 | 9:03 am

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!


October 11, 2011 | 1:01 pm

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.


Viewing 12 posts - 1 through 12 (of 12 total)