#```Lua
1 messages · Page 1 of 1 (latest)
I looked at all this, and figured that combining questionable physics with math.random() really didn't improve over the included RNG alone. I use ```lua
function tryObjectRandomize(obj, pColor)
if string.sub(obj.getName(), 1, 3) == "Die" then -- a named Die xxx
local sides = #obj.getRotationValues()
obj.setRotationValue(math.random(sides))
-- put code dependent on the rotation value here e. g.
-- printToAll(pColor .. " rolled a " .. obj.getRotationValue() .. " with a " .. obj.getName())
return false
end
return true
end
The above completely avoids the need to wait for the dice to settle.