Finding Max Number with Limits
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.
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
-
LiquidGameworks Anchorage, AKPosts: 956
I think you're looking for MAX(floor(game.money/game.price), (game.carrylimit-game.carry))
Give it a try. GS has the Max function, and it'll take the higher of x or y. You get to define x/y any way you want.
Answers
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!