Adding a Display Label to SSH's COMBOLOCK module. (SOLVED)

Started by The_Creep, Wed 26/04/2006 01:46:12

Previous topic - Next topic

The_Creep

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?
If you had nothing left, would you risk it all to change everything?

Ashen

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 property to limit the number of characters displayed:
Code: ags

if (kpdisplay.Text.Length < 6)kpdisplay.Text =  kpdisplay.Text.Append("2");
else Display ("Whoa there! That's enough for now.");


(EDIT: Corrected Append line.)
I know what you're thinking ... Don't think that.

SSH

12

The_Creep

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
If you had nothing left, would you risk it all to change everything?

SMF spam blocked by CleanTalk