Tabletop Simulator

Tabletop Simulator

Counting Bag v2
28 Comments
Lux 8 Dec, 2023 @ 1:50pm 
anyway i can make it so when the back is locked, it doesnt unlock itself?
SinfulPetGirlRD 15 Jul, 2021 @ 11:33am 
would it be possible to make it display not the total value of everything but instead the total of different items in the bag? so like for D&D you put 10 copper/1 sliver/ 2 electrums/2 gold and 2 platinum coins into the bag, instead of it showing the total value of all that it instead shows 5 numbers, each the total of that specif coin in the bag.
Syke 14 May, 2021 @ 9:19am 
Great Mod.
Came across this when i was locking for a bag, which i could use as a backpack for Tabletop RPG's.

I would second what Lorenzetty said. It would be great if you could set a max value for the counting bag. So if you try to add something which would put it above the max value, it would spit it right back out at a specific place in a radius around the bag.
Kinda like the peerless finite bags but with Item value instead of number of objects.

Use case would be That it would be perfect to use as a Bag of Holding where you have a max. capacity of your backpack and then asign "value" or "weight" to item cards for weapons, armor so players have to pay attention to how much they can carry.
saizai  [author] 19 Mar, 2021 @ 3:36pm 
Updated to disable debugging text (oops) and to demote search of Lua *script* (as opposed to Lua *state*) to last place. Otherwise things just get weird, especially with the Bag itself. Code is not data.
saizai  [author] 19 Mar, 2021 @ 2:59pm 
Updated to fix an issue with counting negative values in description text, and to give better examples in the mod layout and in the Lua text.
saizai  [author] 19 Mar, 2021 @ 2:30pm 
Thanks to @The Manx Turtle and @DLC0234, I've made some major revisions…

1. It now is set by default to accept the variables "value", "cost", "price", or "coin" - lower, upper, or title case, in the name, description, Lua code, or Lua save state. E.g. description "Value: -341.50" works.
2. It knows the values "nickel" (5), "dime" (10), and "quarter" (25).
3. It now works with negative and decimal values, for all fields. (This was a bug before in name/description.)
4. It has full recursion, even if the thing you put in isn't a Counting Bag.
5. It has "canasta mode". ;)
6. It has actually working save state. (Oops. ><)
Rambovi 19 Mar, 2021 @ 11:25am 
@DLC0234 yeah i figured it out before xD Sorry for not sharing it.
Bui its still not possible for Card Descriptions. So i added everything into the code
saizai  [author] 19 Mar, 2021 @ 4:34am 
@The Manx Turtle How did you expand it? I'd like to incorporate whatever you did, so that this is fully flexible.

@Findanniin Just use correct Lua numbers. 0.5 e.g. should work, but .5 probably won't.
saizai  [author] 19 Mar, 2021 @ 4:30am 
@Lorenzetty Hm. I guess so. I'd have to make it spit out items that would make it go over the max value — including ones that it already has, if the max was just added eg, if values change or if items are added via sidebar.

Due to TTS' scripting, I'd have to specify exactly where the ejected items go. I guess the most neutral place to put them would be hovering directly above, since I can't rely on any place around it being clear. Or I'd have to have it have a way to set the ejection site, which is a bit of a pain but doable.

What's the use case you have in mind?
DLC0234 27 Feb, 2021 @ 11:59pm 
@Rambovi I emailed Sai and we figured out that if you set the object's value in the scripting manager as value = -x then it will work! (Example: value = -5)
DLC0234 15 Feb, 2021 @ 12:54pm 
This is an awesome item! I have used it for several different games already. But I have the same question as @Rambovi Can you use Negative values? I have not figured it out yet.
Rambovi 5 Dec, 2020 @ 6:35pm 
HEy, wanna add your Bag for a Game. But i need to also use cards with -5 and -15. Is it somehow possible to use negativ count?
Lorenzetty 30 Nov, 2020 @ 5:17pm 
Hey, is there a way to set a maximium value capacity of the bag? Most like Peerless's Finite Bags but with a maximum value of capacity (not quantity of objects inside)!
The Manx Turtle 21 Nov, 2020 @ 5:51pm 
@saizai Thank you for putting these ideas together (and respectfully crediting their sources). My brother and I put one of your bags in a Double Canasta card game and then expanded on the bag's ability to evaluate a Deck of scripted Cards. It was a bit tough, but we figured out how to obtain the cards' "value" variable by analysis of the lua_scripting property.

Our play group has several retirees in it, so the counting bags are expected to save us so much time (and mistakes) each Sunday.
Collevatti 7 Sep, 2020 @ 8:11am 
@Findanniin if you go to line 151 in the script and make the value = totalValue/100, you just need to ajust the value of individual coins... gold = 100, silver = 10, copper = 1... just put in their description Value: 100, Value: 10, and Value: 1

@saizai Great Mod, loved your script :steamhappy:
Niki 13 Jun, 2020 @ 7:42am 
This is brilliant, thank you.
Is there a script edit I can do to display values smaller than 1?
I know that the counting bowl you based this on will display .5 values for example, and I'd like to use this so count silver/copper this way.
Flyndad 28 Mar, 2020 @ 11:08pm 
Hmm,... I am simply wanting to change the name of the Model and it's value and then have the bag add the values of all the models placed in the bag. Every time I change the name of the "coin" from coin to "anything other than coin" it doesn't add. I know I have to be missing something simple. ?? Thanks,..
saizai  [author] 31 Jul, 2019 @ 2:30am 
@azure falcon the bag stores its own value in its value attribute, so if you put multiple bags in a bag it should add them up fine just like anything else, so long as it has enough time to count its own contents first. I don't know what duplicating a bag would do though; TTS is very weird about the contents of bags (they only pseudo-exist)
Azure Falcon 17 Jul, 2019 @ 11:25pm 
Trying to get a counter to count the total of multiple bags.
How do you get the value of the bag?
star 10 Jul, 2019 @ 11:41pm 
And you may found that ten 0.1 are not equal to 1:
x = 0
for i=1,10 do x = x + 0.1 end
print(x == 1) ----> false
star 10 Jul, 2019 @ 11:38pm 
It's better to use integer numbers, because real numbers may show you some magic.
print(0.1 + 0.2 == 0.3) ----> false
saizai  [author] 26 Jan, 2019 @ 4:08am 
@wileybot Don't know what to tell you on that. It adds whatever you put in the script. I don't know if Lua has issues with non-integer numbers.
wileybot 17 Nov, 2018 @ 3:44pm 
This is a very cool mod, thank you for making it. I was trying to get it to count coins and give a total value in gold. But it will not accept a .01 or .001 value. It counts both as 1. I am new to this so I am not surprised if user error on my part.
saizai  [author] 14 May, 2018 @ 6:04am 
@razuvious You can just edit the script to change the variable name. "Value" isn't special. I believe it already takes decimal values just fine, so long as the source gives one.
Razzuvious 9 May, 2018 @ 12:00pm 
Annnd since I can't edit, also is it possible to get it to take decimal values. Now that I started thinking, it would make a great wallet for our game too. Would just be nice if it tracked an actual Gold value while factoring in Copper/Silver values.
Razzuvious 9 May, 2018 @ 11:25am 
Would it be possible to change the variable from "value" to "weight"? Wouldn't mind using this as the parties Bag of Holding in our D&D game, that way I can actually see how much weight is currently in the bag visibily without having to go through and manually figure it out myself.

I'll try and figure it out myself later, but if you can give me a heads up of where to look I'd appreciate it ^_^

Thanks!
Popcorn 15 Apr, 2018 @ 12:38pm 
spunky use of lua!
darleth 12 Apr, 2018 @ 1:08am 
thanks a lot...