This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ZombieTurtle's profile picture

Help Limit Read

Started by ZombieTurtle, 15 August 2014 - 11:13 PM
ZombieTurtle #1
Posted 16 August 2014 - 01:13 AM
Um just wanted to know how to limit number of keys pressed
because i'm making a PIN lock for my Pocket Computer(Private Use)
and i want to limit it to 4 Could someone tell me how to do this
and explain it other wise i'm most likely to mess up
theoriginalbit #2
Posted 16 August 2014 - 01:58 AM
You have two solutions, the first is to allow them to enter any number of characters and just validate how many are entered, the second solution is to rewrite the read function so that you can specify a character limit and have it stop adding input once that limit is reached. I have an implementation of read (follow the programs link in my signature) that does just that, as well as a few other improvements, if you don't want to implement the function yourself.