Logic problem with coinage in script

1536636678
I've created a script that lets me add and subtract coins for my players, and everything works great except for the subtraction of coins. I am having a hard time working the logic to account for all scenarios. I make a general check to make sure they have enough overall for the transaction by comparing cp equivalents, and if they have enough coinage downstream (in smaller denominations) it makes change just fine. It's when they don't have enough downstream but they do upstream that I can't figure out. For instance, if a player has enough cp and sp to cover change for the gp they are spending it works great. However, if the player has 0 cp, 0 sp, and 5 gp and they want to buy something that costs 10 sp, so all I'll get is a negative cp covering the expense and never touch the gp. I need to figure out how to know to look upstream for coins to convert. Anyone ever figure this out? I'm banging my head against the wall. Maybe that's why...  ¯\_(ツ)_/¯   Thanks! BTW I'm trying to leave coins as they are as much as possible so it is up to my players to convert their coins when they get too many.
1536640130
I have not used it, so I do not know the details, but there is a script called CashMaster that has a lot of functionality: https://app.roll20.net/forum/post/5950228/script-cashmaster-5e-a-simple-script-to-manage-a-partys-money
1536647914
Rabulias said: I have not used it, so I do not know the details, but there is a script called CashMaster that has a lot of functionality: https://app.roll20.net/forum/post/5950228/script-cashmaster-5e-a-simple-script-to-manage-a-partys-money CashMaster does not work with the 5e Shaped Sheet. Already tried it, which is why I'm writing my own. On the up side, I think I've got it figured out. I guess we'll see tomorrow when I start the laborious process of testing.
1536649996
Arthur B
Pro
API Scripter
Ben L. said: Rabulias said: I have not used it, so I do not know the details, but there is a script called CashMaster that has a lot of functionality: https://app.roll20.net/forum/post/5950228/script-cashmaster-5e-a-simple-script-to-manage-a-partys-money CashMaster does not work with the 5e Shaped Sheet. Already tried it, which is why I'm writing my own. On the up side, I think I've got it figured out. I guess we'll see tomorrow when I start the laborious process of testing. Hi, if it's of any help: I temporarily removed support for the Shaped sheet after they did a bigger change that affected how money is handled in the sheet.  Once I have some time to wrap my head around it, I might add support for the Shaped sheet again (it will require quite some rewriting of the code). Right now I'm too busy with real-life stuff (just changing job, toddler starting at daycare, lots of family visits and so on), and I don't even have time playing D&D, leave alone doing some programming for roll20. Sorry.
1536665639

Edited 1536665941
Michael G.
Pro
API Scripter
CashMaster may presently be incompatible, but that doesn't mean it can't be a reference point for you. The underlying logic (for the stock coins) is the same in both, it's just that interfacing with the Shaped Sheet is a bit weird since the update.  It's not impossible though, and I've been slowly adding functions that can be sheet agnostic.  The underlying principle of updating its coins is actually the same as what we use in the new ShopMaster update for inventory alteration.  It's just a matter of propagating that logic through the rest of the code that's a pain. And like Arthur, I've also got a ton of life things going on at the moment.  My party uses the OGL sheets, so I've not been overly incentivized to do the Shaped Sheet either.  I'd guess at least a month before I can get around to it. I would recommend taking a look at the function ChangeMoney() in the intervening time though.
1536688799
Just finished my script last night. Works like a charm. I'll share once I clean it up a bit. :)