Tabletop Simulator

Tabletop Simulator

Universal Chip Converter Script v2.0
21 Comments
Se7ntus 25 Oct, 2016 @ 11:53am 
Hey Mr. Stump, im in the making of the best blackjack table and i REALLY need your help with scripting your chip converter!
Wyan 8 Oct, 2016 @ 3:39am 
Alright man i'll give it a try.
MrStump  [author] 8 Oct, 2016 @ 3:16am 
Issue 1, you have "tierUp" set to invalid values for a few of your chips (0) which would result in chips being devoured but not getting anything in return. Lines 76 and 77. Secondly, I've gotta new version of the script out which does NOT require the tierDown, but you can keep using the version you have. See my update in the description though to determine if you want to upgrade.

Also, if your chipList is not correctly formatted, it CAN cause TTS to lock up and die. The reason is the "return" loop in the tradeUp function. Avoid tradeUp while you are debugging the code to avoid crashes.

Thirdly, when you move the code to another object, or combine it with a lot of other code, it is a lot harder for me to troubleshot because I can't be sure what you have or have not changed. But give the fixes I've mentioned a try and see how it goes.
Wyan 7 Oct, 2016 @ 8:38am 
It's 1:30 in the morning in Australia. Feel free to add me on steam. I'll upload my version of the map when i get up.
Wyan 7 Oct, 2016 @ 8:37am 
Downloaded this map about 4-5 days ago. the trade up script was messy. And only really supported $1-$100k chips. So i replaced it with your script. Keep in mind there is two converter spots. I just changed a few numbers. I've hosted an multiplayer lobby today. Twice it has crashed. Once in an multiplayer lobby with someone trying to trade up 53 stack of 1ks. Second time in an multiplayer lobby by someone trading up nothing. It has also crashed alot on singleplayer when i throw in random amounts of chips of random values between $10 - $100t.

code -- http://pastebin.com/junZPbM4

map(without custom chips) -- https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=774292858

My lua is pretty shit.

Thanks for helping
MrStump  [author] 7 Oct, 2016 @ 7:35am 
The value of the chips has no impact on the script, it only reads chip names and the "tierUp" value you assigned to them. I am unable to reproduce any of the bugs you are mentioning on this test table that comes as part of the workshop item.

Upload you full script to Pastebin and I'll take a look for you.
Wyan 7 Oct, 2016 @ 3:13am 
Edit: I found the issue of the crashing. it appears when i try to convert chips with way higher values it crashes. I tried to convert 5 100k's and 10m it crashed.
Wyan 7 Oct, 2016 @ 2:55am 
I set everything up right. I pile in some chips. Sometimes it works. Sometimes the chips get sucked up and i get nothing. Sometimes my game crashes. Sorry, but i don't think this works anymore.
MrStump  [author] 10 Sep, 2016 @ 5:09pm 
Sure. And for everyone else, if you get an error, check the following 3 things.

(1) When you right click on each chip, make sure the Name field has the name of the chip that you put into the script.

(2) Check you scripting zone and its GUID. Make sure the GUID of the scripting zone matches what is in the code.

(3) Make sure the GUID of the INFINITE bags all match each entry.

These are the usualy problems I see.
Dev 10 Sep, 2016 @ 2:01pm 
when i tried this i get the error: error calling Lua function tradeUp: chunk_1:(97,4-43): attempt to index a nil value

Ive added you can you help me?
Ottomated 1 Sep, 2016 @ 4:55pm 
Very true.
MrStump  [author] 1 Sep, 2016 @ 12:17pm 
That have value well beyond the standard float limit.
Ottomated 1 Sep, 2016 @ 10:08am 
@MrStump what do you mean "that doesn't blow past it"?
Ottomated 1 Sep, 2016 @ 10:07am 
@Unreal Ed Actually, while beta testing my blackjack game, a player who legitimately made it into the octillions tried to trade up 10 x 1 octillion and it rounded it down weirdly, giving him a couple chips of each value that added up to about 10 octillion. So yes, it was an issue.
MrStump  [author] 1 Sep, 2016 @ 4:56am 
Ed, I didn't meant to imply it was impossible, just impractical to do in a "universal" way. And as far as going over the float limit, I personally have yet to see a blackjack game someone has made that doesn't blow past it haha
Unreal Ed 31 Aug, 2016 @ 5:55pm 
The float problem is a non-issue in most games. Who's going to have 2,147,483,647 in chips? The "chips don't have value" is also fixable: you can attach scripts to them and then add a value variable. The mod with the script would have a chips with scripts attach, and if you wanted to adapt that to another mod's chips you'd have instructions on how to adapt it.
Ottomated 31 Aug, 2016 @ 4:03pm 
I know how to script, and I created an potentially unlimited in value converter in my mod. I ran into the float problem, so I put an 'ID' for each chip in its description. i.e. 50:1,100:2,500:3,1000:4, all the way to 100 decillion:34 or so. I also used your trade up amount values, but not the trade down values as they aren't necessary; I can just check the trade up value for the next chip down. I used "Simple Scripted Chips" for a human number display method.

For trading down, I used a simpler method of only trading down if there is one chip in the converter.
MrStump  [author] 30 Aug, 2016 @ 7:58pm 
2 issues with that type of script. 1) chips do not have inherent value, so you'd need to name them a specific way for the script to recognize them. 2) Lua uses floats, which cap out after too many digits. So when people have Octillion value poker chips, it is difficult to make it all work.

What you are asking for is generally possible, but I can't make a "universal" one. Add me on steam if you'd like to give me some specifics to make one for ya.
Unreal Ed 30 Aug, 2016 @ 4:49pm 
I'm loving all these scripts you've been adding recently! Any chance you could make one that is counts how much money you have in chips in a certain zone? It would display player's money totals in the note area (or your own scoreboard? or somewhere else? not sure the range of what's possible).
Ottomated 30 Aug, 2016 @ 8:54am 
Never mind, I just realized. This is EXACTLY my method that I used in "Bob's Blackjack"! Great minds think alike, eh?

Also, it would be nice to add a text element showing the total of the chips currently in the zone.
Ottomated 30 Aug, 2016 @ 8:39am 
Does it have a maximum, or can it go up into the octillions?