SOLVED: Incorrect % shown on label

Started by Slasher, Thu 25/04/2013 09:15:35

Previous topic - Next topic

Slasher

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
  Ltotal.Text = String.Format("You have rescued %d%% of the missing children",(Children*100)/maxchildren);


Based on:

Code: AGS

Children=(Children+1)




Crimson Wizard

#1
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.

Slasher

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.



Slasher

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.


Crimson Wizard

#4
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.

Khris

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.

Slasher

It was Global variable (maxchildren)and not starting game again from scratch.

It seems to be ok now  (nod)

cheers

SMF spam blocked by CleanTalk