Tabletop Simulator

Tabletop Simulator

Camel Up 2.0 (backwards camels)
Xtal Lattice 2020 年 10 月 28 日 下午 4:27
How to make the dice roll automatically when leaving the pyramid
Here is how to make the dice roll automatically when they come out of the pyramid:


Changes to the Global script

Add to onLoad():

-- Holds the dice object that leaves the pyramid so that we can set the flag within the dice. Used for rolling. diceFlagObj = nil


Add to getObjects():

pyramid = getObjectFromGUID('2743e2')


Add to the root of the Global script:

function onObjectLeaveContainer(bag, obj) -- Set the flag for dice leaving the pyramid so that they will roll upon landing on the board. if bag == pyramid then diceFlagObj = obj startLuaCoroutine(Global, "setDiceFlag") end end -- Coroutine used to set the flag for dice leaving the pyramid. Used for rolling when they hit the board, since die positions are preserved in containers. function setDiceFlag() -- When objects leave a container, it takes a moment to spawn before they exist. Pause so they exist when we act on them. for i=1, 5 do coroutine.yield(0) end -- Set the flag in the dice object. diceFlagObj.setVar('rollFlag', 0) -- Necessary for coroutines. return 1 end


Script for each dice object:

-- Dice -- When the die comes out of a bag and hits the table, automatically roll it. function onLoad() -- Flag to indicate whether the dice is ready to roll. Without the flag, the dice will roll endlessly every time it bounces. rollFlag = 2 end function onCollisionEnter(collisionInfo) if rollFlag == 0 then self.roll() rollFlag = 1 end end


I tested this, and it works perfectly on my end.
最后由 Xtal Lattice 编辑于; 2020 年 10 月 28 日 下午 4:28
< >
正在显示第 1 - 2 条,共 2 条留言
wailwhale  [开发者] 2020 年 12 月 22 日 上午 11:39 
Thank you for the update man, I will work on implementing it as soon as I get the chance :)
Xtal Lattice 2020 年 12 月 26 日 下午 6:22 
Glad I could help!
< >
正在显示第 1 - 2 条,共 2 条留言
每页显示数: 1530 50