Hi
I'm not sure if this belongs in beginners forum or in the technical archive under the Module thread, but I figured this question is more relevent to labels than it is to the module.
I'm using SSH's awsome Combolock module, which I've modified to that when the player punches in a number
it displays in a Label at the top of the GUI, here is the code:
//in the button press code
//kpdisplay is the relevant label
Combolock.Press("2");
kpdisplay.text = (Combolock.Entered);
what I discovered is that the label has no set limit on the amount of characters it can have entered, now part of the puzzle I'm building relies on the fact that they can only enter 6 digits, does anyone know how I can restrict a GUI label to 6 characters?
You shouldn't have to limit the number displayed. The module's ComboLock.Status() function checks the length of the currently entered String against the actual combination - so if you've got the module working right, when you get to 6 characters it should take care of the limiting for you.
On a more general note (and to justify this being here, rather than in the Module thread), you could probably use the String.Length (http://www.adventuregamestudio.co.uk/manual/String.Length.htm) property to limit the number of characters displayed:
if (kpdisplay.Text.Length < 6)kpdisplay.Text = kpdisplay.Text.Append("2");
else Display ("Whoa there! That's enough for now.");
(EDIT: Corrected Append line.)
As Ashen said...
yeah I messed with the code a bit to suit my needs, however me messing with code is equivalent to someone kicking their computer till it works then wondering why the mouse won't move :) but Ashen's code's got it working again thanks