Code:
--This makes a blank table used later
ref_diceWatched = {}
--Watch for randomized dice (hitting R on them)
function onObjectRandomize(object, player_color)
if object.tag=="Dice" and ref_diceWatched[object]==nil then
ref_diceWatched[object] = true
watchDieRoll(object, player_color)
end
end
--Watch for dropped dice (physically rolled) (possible cheat warning)
function onObjectDropped(player_color, object)
if object.tag == "Dice" and ref_diceWatched[object]==nil then
ref_diceWatched[object] = true
watchDieRoll(object, player_color)
end
end
--Function which runs a coroutine to watch the dice
function watchDieRoll(die, color)
function watchDieRoll_routine()
while die.resting == false do
coroutine.yield(0)
end
ref_diceWatched[die] = nil
return 1
end
startLuaCoroutine(Global, "watchDieRoll_routine")
end
He is one I wrote a while back. Those 3 empty lines in the watchDieRoll function are where you would insert any code you want to have ru nonce the dice come to rest.