Hi all,
I did a search on 'increment,' but found nothing, so I'm hoping the Collective can help.
I'm working on a treasure generator for S&W. If you're not familiar, the system starts with a total gp value but lets you "trade out" cash for other bits. For example, for every 100gp value of the treasure, there's a 10% chance that you convert that 100gp into a small gem or minor magic item.
I've assigned the total gp value to a variable {$coinCount}, and for every trade out, I need to reduce that number by the value of the trade out.
For example, if I start with {$coinCount} = 500, I roll 5 times for a trade out (1 roll per 100gp). Let's say 2 of the rolls generate gems - regardless of their value, {$coinCount} now equals 300gp.
How do I decrement {$coinCount} every time a trade out occurs?
Cheers,
Comments
//GP value of treasure to be rolled. Set: CoinCount = 1526 // Divides GP value by 100, rounding down to the nearest whole number. // This is the number of chances you have of rolling a gem. Set: GemRolls = {floor ({CoinCount}/100)} // The Treasure's Starting GP value in gems: set to 0 to start. Set: GemValue = 0 //This is the generator's main table. Table: TotalTreasure The total value of this treasure is {CoinCount} gp. \n\n& Rolling for gems... \n& [@Repitions&#93; \n& The final treasure value is {CoinCount} gp in coins and {GemValue} gp in gems. // This table performs a number of d10 rolls equal to the number of GemRolls. Table: Repitions [@{GemRolls} RollIt] // This table gives a 10% chance of rolling up 100 gp worth in gems per 100 gp found in the treasrue. // Every roll of 10 subtracts 100 gp from CoinCount and adds it to the treasure's GemValue. Table: RollIt Type: Lookup Set: RollNumber = 0 Roll: 1d10 1 - 9: {RollNumber == RollNumber + 1} & Roll number {RollNumber}[: ] & <font color=purple>No Gem.</font> \n 10: {RollNumber == RollNumber + 1} & Roll number {RollNumber}[: ] & <font color=red>Gem.</font> & {CoinCount == CoinCount - 100} & {GemValue == GemValue + 100} \n& The current treasure value is now {CoinCount} in coins and {GemValue} gp in gems.\n