Limiting Multiple Edit Boxes

This forum is currently in read-only mode.
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • I'm working on a game that uses your text to adjust an RPG characters stats each round. Its for a challenge on indirect control in just a few more days.

    For 'simplicity' sake I decided to use multiple edit boxes, each one controlling a stat of its own.

    I'm limiting the amount of text you can use to create the whole sentence and want all of the edit boxes to draw from a total amount.

    Its working, mostly, but I'm getting some odd results.

    The max is supposed to be 25, but the first box you edit will only go to 13..the second to 6, 3, 2, and 1. If you edit them out of order you get slightly different results but it always adds up to the max amount.

    I can't figure out why it wouldn't let you fill any box to whatever length you want, as long as you don't go over the max amount.

    Heres the cap

    http://www.box.net/shared/4iu3508n0m

    Since I haven't updated lately, I'd appreciate a description instead of a cap file in return.

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • When you set the editbox's text limit you need to take into account the editbox's text length.

    e.g. instead of

    -> Eb_Str: Limit text to ST_Face.Value('LeftoverStringLength') characters

    use

    -> Eb_Str: Limit text to len(Eb_Str.Text)+ST_Face.Value('LeftoverStringLength') characters

    Also on the "HUD" event sheet, event 14,

    invert the condition

    then change it to less or equal instead of greater or equal.

    The only other issue that comes up is that limiting text length to 0 does nothing. so if you use up all 25 characters on the first two edit boxes, you will still be able to input one character on the others.

    Here's a quick example:

    Setup:

    * 3 different Editboxes

    * make all the edit boxes members of the Blue Family

    Code:

    + System: Always (every tick)
    -> System: Set global variable 'extra' to 25-len(EditBox.Text)-len(EditBox2.Text)-len(EditBox3.Text)
    -> Blue: Limit text to len(Blue.Text)+global('extra') characters
    
    + System: global('extra') Equal to 0
    + Blue: Pick by len(Blue.Text) Equal to 0
    -> Blue: Set read only On
    
    + System: Else
    -> Blue: Set read only Off[/code:1u2i8k3a]
    
    -Cheers
  • Its working perfectly, thanks a ton.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)