# How should I do this formula?

#1

I wanted to make things a bit more complicated for myself yet again, so I was wondering how can I do it since my past attempts were fruitless so far.

*set stamina -(10/endurance*50+30)
-When I tried it on my calculator, it worked. If say, endurance =30, it will subtract 53 from Stamina.
-the 30 at the end is like, if you choose the wrong choice, the bigger it will be.

#2

I’m not sure where you got “53” from as the closest as I can manage with your stated values is to reduce Stamina by 47, which would be something like:

``````
*set stamina (stamina - round(((10 / endurance) * 50) + 30))

``````

Some general guidelines for doing this type of thing in ChoiceScript -

• break down each step of the calculation using brackets, as for (e.g.) a spreadsheet calculation.
• similarly, the exact placement of those brackets will determine the order in which values are calculated
• best to use ‘round’ for any sum involving division, so it’s always applying a whole number value - an integer - in the final step e.g. (stamina - (whole number))
• I find it easier (for future reference) to use the variable for both the *set command as well as within the formula, as shown above, so it’s simply *setting the final value
• above all, remember that the more complicated you make it, the harder it will be for you to test properly. Just because you can do it with CS, doesn’t mean you should!

#3

Or if it’s any easier, just do it in steps:

``````
*set modifier round(10 /endurance)
*set stamina (stamina - modifier)
*set stamina (stamina + 30)

``````

I’m not sure if that’s exactly right for this particular example, but hopefully it illustrates my suggestion well enough.