Questions from a coding noob

Hey everyone, I am new to coding and programming and considering this I thought it would be better to make a whole topic about the various questions I will undoubtedly have often.

My first question is I have a choice and I want to affect a stat based on the choice someone makes but it’s not quite working out. Code is pasted below vvvvv

*fake_choice
    #"Look, I don't have all day unlike a certain girl who won't move on." You say in obvious  annoyance.
        
        ${sreputation}
        *set sreputation %-5
*page_break
    #"I'm not trying to rush you but you don't absolutely have to decide now. I can come back later?" You gently tell her as the time ticks by.
        ${sreputation}
        *set sreputation %+5
*page_break
    #Your not really in any rush to get to a place as miserable as your high school. You settle yourself for lateness and continue to guide the girl to her afterlife.
        ${sreputation}
        *set sreputation %+10
*page_break

When I click a choice in testing the next page only shows “10” where script is but the stats don’t change. Does anyone have any suggestions?

Right now, you’re displaying your current stat value BEFORE you change it. Try having the stat display ${sreputation} and the stat setting *set sreputation %+5 switch lines.

*fake_choice
    #“Look, I don’t have all day unlike a certain girl who won’t move on.” You say in obvious annoyance.
        *set sreputation %-5
        ${sreputation}
        *page_break
    #“I’m not trying to rush you but you don’t absolutely have to decide now. I can come back later?” You gently tell her as the time ticks by.
        *set sreputation %+5
        ${sreputation}
        *page_break
    #Your not really in any rush to get to a place as miserable as your high school. You settle yourself for lateness and continue to guide the girl to her afterlife.
        *set sreputation %+10
        ${sreputation}
        *page_break
1 Like

okay so i did as you said, i wasnt aware that code line was for displaying the stat. oops. I took that ${sreputation} out. The problem now is the %-5 doesnt work and the %+5, and %+10 are added incorrectly. it pops up as 14, and 19.

That’s just the way Fairmath works.

%-5 tries to make your variable’s value smaller by 5% of what it currently is. However, it only subtracts whole integers. Since 5% of 10 is 0.5 (I’m extremely confident your current sreputation value is 10, please correct me if I’m jumping to false conclusions,) Fairmath won’t subtract anything.

When making a variable’s value larger, Fairmath basically adds the percentage you told it to add… except, NOT the percentage out of 100. Instead, the percentage out of… I’m not sure how to best describe it. Basically, the percentage out of what’s left when you subtract your variable’s current value from 100. Since 5% of 90 is 4.5, and Fairmath ignores decimals, %+5 adds 4. Since 10% of 90 is 9, %+10 adds 9.

It’s hard to explain and honestly somewhat difficult to visualize, but it’s to make sure your variable’s value never goes over 100 or under 0.

However, assuming your variable’s current value actually is 10 and not something else, Fairmath is functioning exactly as intended for this situation.

1 Like

I see. You are correct by the way in assuming the base number is 10 ^^.
I guess then the coding is correct? Okay then is there another system that you know of I could use instead of fairmath because the game I am developing is heavily influenced by stat gain and loss.

What if you simply make the bump bigger than %+5? %+10 is a good place to start.

1 Like

Yes, your coding seems to be correct.

Fairmath is probably the easiest way to handle lots of stat gain and stat loss, especially if you want to display those stats as percents on the stats page.

As @Gower mentioned, bigger changes are a good idea. I believe the official Choice of Games recommendation for using Fairmath is %+10 or %-10 for “small” changes, %+20 and %-20 for “medium” changes, and %+40 and %-40 for “big” changes. Changes as small as %+5 aren’t recommended; they’re generally considered too small.

(The recommendation is about halfway down the page I just linked, in the “We recommend that you always/only use Fairmath to update percentages.” heading in the “Percentile stats and Fairmath” section.)

2 Likes

Oh, Oh okay I see what you guys are talking about. Thanks for the help!

1 Like