Limiting Multiple Edit Boxes

For questions about using Classic.

Post » Sun Apr 25, 2010 4:51 pm

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
[url:ilzuqjmt]http://www.box.net/shared/4iu3508n0m[/url:ilzuqjmt]

Since I haven't updated lately, I'd appreciate a description instead of a cap file in return.
Thanks
B
2
S
2
G
3
Posts: 114
Reputation: 1,553

Post » Sun Apr 25, 2010 7:43 pm

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:
[code:1u2i8k3a]+ 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
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Mon Apr 26, 2010 1:55 pm

Its working perfectly, thanks a ton.
B
2
S
2
G
3
Posts: 114
Reputation: 1,553


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests