Tabletop Simulator

Tabletop Simulator

View Stats:
Athena LLS Jul 6, 2016 @ 12:53pm
Card counter script
Just wondering if anyone knows if theres a script to count the value of cards auotmaticlly.

Thanks
< >
Showing 1-9 of 9 comments
Sekkuar666 Jul 6, 2016 @ 2:01pm 
Hmmm
That's something hard to accomplish on it's own.

Making the script to count the cards is easy, however, you need to make it on your own save, since it will need to reference your deck
Athena LLS Jul 6, 2016 @ 2:33pm 
ah,
Have any idea how i would write that? im not the best at scripting.
Aro Jul 6, 2016 @ 6:08pm 
Check out the blackjack scripting example, it pulls the value from the cards.
Sekkuar666 Jul 7, 2016 @ 11:00am 
Hello, sorry for taking long to reply, I've been working on something for you.

Like I said on my previous reply, context is important to make this work, so, I created an example mod for you.
http://steamcommunity.com/sharedfiles/filedetails/?id=719613138

First of all, there's two things you need to understand:

First: There's no way for the game to know the actual value of the cards. What I did here was to type the actual value of the cards into their name, and then have the script check the card name whenever it enters/exit the script zone.

Second: I've made a mod to show, because there's two things you need in place for this to work. A counter object (with the ID value saved on the script) and a scripting zone (you can create those with the zone tool in game)

Although in theory it would be possible to have several zones, each with its own counter, for this script, I've assume there will be only one script zone. If you create more than one, the behaviour will be kind of weird.

In any case, whenever you drop a card on the script zone, it will add its value to the counter. Remove the card, it will remove the value.

I've put the values on the card myself, you can change the values to whatever you need (and use your own deck, just make sure to put a value on every card)

For this example, the values for the letter cards are
J = 11
Q = 12
K = 13
A = 1
JOKER = 0

Here's the script I've used.
If you want to use it on another mod, just make sure to copy the counter ID and paste it on the script, and create a scripting zone somewhere. It should work fine.
http://pastebin.com/bs7Q3JBq
Last edited by Sekkuar666; Jul 7, 2016 @ 11:29am
Athena LLS Jul 7, 2016 @ 1:40pm 
Thank you :) ill be sure to check it out. This will make it a lot easier to understand
Athena LLS Jul 9, 2016 @ 12:24pm 
So i was playing around with the scripting on my table and it seemed to work very well but then i realise since there is only 1 scripting zone you cant use that for different counter ID's so i was wondering if there is a way on changing it so it takes it from a hidden colored zone instead.

If this is possible it would mean u could make different counters just im unsure how i would change the code to grab different zones.
Last edited by Athena LLS; Jul 9, 2016 @ 12:25pm
Sekkuar666 Jul 9, 2016 @ 2:36pm 
No you can't.
The script only has an event for scripting zones, not hidden zones.

One way I thought of solving this problem would be to lock something named on the zone. And then have the counting script associate each name to their own counter ID.

But... honestly, that's too much work.
Sekkuar666 Jul 9, 2016 @ 2:44pm 
Other way would be to place the counter inside the zone and have the script find the counter to update instead of having to set the ID yourself.

This way only the counter (or counters) inside the zone would be updated and you could have as many zones as you wanted.
Athena LLS Jul 9, 2016 @ 2:48pm 
Nice idea thanks XD now i need to find how to to code this haha
< >
Showing 1-9 of 9 comments
Per page: 1530 50

Date Posted: Jul 6, 2016 @ 12:53pm
Posts: 9