Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Thu 25/04/2013 09:15:35

Title: SOLVED: Incorrect % shown on label
Post by: Slasher on Thu 25/04/2013 09:15:35
Hi

Dilemma time.

For some reason I find below does not give correct shown % when maxchildren is reached (17) it shows 106%.

Correctly the label should read Children times 100 divided by maxchildren

Int maxchildren set at 17.

I thought it was alright some time ago.

Code (AGS) Select
  Ltotal.Text = String.Format("You have rescued %d%% of the missing children",(Children*100)/maxchildren);


Based on:

Code (AGS) Select

Children=(Children+1)



Title: Re: Incorrect % shown on label
Post by: Crimson Wizard on Thu 25/04/2013 09:33:36
You might have a mistake in program logic.
If you will put Children == 18 into your formula (with maxchildren == 17), you will get 106%.
This means your children count gets larger than maxchildren at some point.
Title: Re: Incorrect % shown on label
Post by: Slasher on Thu 25/04/2013 10:29:00
Hi Crimson

Yes, I understand.

The Children Label itself shows 17 (which is maxchildren) so it can't be 18.

Both 17 and lower will show %. 17 being 100% on the Ltotal label.

It must be a room script error. I will have to take the room apart and check.


Title: Re: Incorrect % shown on label
Post by: Slasher on Thu 25/04/2013 11:24:48
QuoteI don't believe it!
As Victor Meldrew would say  (laugh)

I had amended maxchildren and stupidly forgot you have to play game from start.

This is one part of the compile (variable) system I hate!

Anyhow, guess I'll have to play from start with fingers crossed.

Title: Re: Incorrect % shown on label
Post by: Crimson Wizard on Thu 25/04/2013 11:31:28
You could make debug functions that would correct your variables at runtime.
Replaying all game from start simply because couple of vars changed is waste of time. :(

For example, a simple GUI window, with buttons to correct (increase/decrease) some important stats.
Title: Re: Incorrect % shown on label
Post by: Khris on Thu 25/04/2013 12:48:53
Label text doesn't automatically update when the variable changes unless it is set each frame in rep_ex.
So I guess the game increased maxchildren to 18, updated the percentage label but didn't update the maxchildren label.
Title: Re: Incorrect % shown on label
Post by: Slasher on Thu 25/04/2013 13:15:01
It was Global variable (maxchildren)and not starting game again from scratch.

It seems to be ok now  (nod)

cheers