Finding Max Number with Limits

BluSpyderBluSpyder Member Posts: 129
edited April 2012 in Working with GS (Mac)
I'm trying to find the max outcome of a number that has 2 requirements (max of what they can afford and max of carrying space). This number is the amount that the user wants to buy of an item.

This specific button changes the number to the max they can afford AND carry.


EX. game.amountToBuy = floor(game.money / game.price)

This equals how much they are able to purchase. BUT I need this number to also fit with the carrying limit.

Say the limit is 10, and they are already holding 6 items. So the number needs to be 4 if they can afford it. What can I add into the formula to do this?

EX2. game.amountToBuy = floor(game.money / game.price) .....with a max of (game.carryingLimit - game.carrying) ?

I'm not the best at explaining things, let me know if this makes any sense.

Best Answer

Answers

  • BluSpyderBluSpyder Member Posts: 129
    edited April 2012
    Thanks for the reply.
    I completely forgot about the max and min functions....*sigh* I was looking right over them trying other functions....

    It's actually Min that i was looking for to find the lowest of either one. I think I was explaining it wrong, that's why you suggested Max. Thanks for helping me realize this!
Sign In or Register to comment.