Tabletop Simulator

Tabletop Simulator

View Stats:
Sandling Feb 24, 2017 @ 12:36pm
Infinite 'Random' Bag
Curious if anyone ever wrote (or can help) with a script to have multiple options (randomized on each pull) coming out of Infinite Bags - If so it would help me immensly with some custom boardgame design! :)
< >
Showing 1-6 of 6 comments
Sekkuar666 Feb 24, 2017 @ 12:38pm 
Can't do.
Infinite bags are for single items.

You could make a self shuffling bag and just put the item back after you pulled it.
(you can always copy + paste a new one if you need to keep the item as well)
Last edited by Sekkuar666; Feb 24, 2017 @ 12:40pm
Sandling Feb 24, 2017 @ 12:48pm 
That's what I've been doing at the moment indeed, but sometimes the results of the bag get pulled away by our players by accident, and rolling a dice for random results has been a timesink when you need to keep an eye on everyone xD

Perhaps a clumsy way would be to script a normal bag to know what object got pulled, putting a replica of said item 'back' in the bag?
Skor Feb 27, 2017 @ 8:53am 
Copy/paste this script onto a bag and try it out. Note that it won't work immediately on that particular bag that you paste the script to; you'll have to do one of the following: save and load the game with the scripted bag; save it to chest and spawn a new one from there (the script will work on the newly spawned one); or copy/paste it and the pasted one will work.

--[[ If an object is removed from this container, clone the object and put the clone into the container --]] function onObjectLeaveContainer(container, object) if container == self then self.putObject(object.clone({['position'] = {self.getPosition().x, self.getPosition().y + 2, self.getPosition().z} })) startLuaCoroutine(self, 'delayedShuffle') end end --[[ Wait three frames to allow the clone time to spawn and enter the container, then shuffle the container --]] function delayedShuffle() for i = 1, 3 do coroutine.yield(0) end self.shuffle() return 1 end

Edit: I put it up on the workshop too: http://steamcommunity.com/sharedfiles/filedetails/?id=873630529
Last edited by Skor; Feb 27, 2017 @ 9:15am
Sandling Feb 27, 2017 @ 9:32am 
Many many thanks for this <3

Still an absolute newbie at scripting in TS, so the help is truly appreciated :)
Hoping I can eventually return the favour to help others in need when I've learned the language a bit more myself
Sekkuar666 Feb 27, 2017 @ 11:37am 
That's an interesting use of the new event with clone object. Haven't thought of it that way.
Good job!
Marquise* Mar 2, 2017 @ 8:36pm 
I have ti try this! Thanks!
< >
Showing 1-6 of 6 comments
Per page: 1530 50

Date Posted: Feb 24, 2017 @ 12:36pm
Posts: 6