Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
That would be great if I understood how to properly start/end the process and where to place it, assuming it needs to be placed in a certain part of the script. There is also the issue of what to place in the script for it to understand the variables it is grabbing at any given time...
I am using the scripted roller from this mod: https://steamcommunity.com/profiles/76561198025190893/myworkshopfiles/?appid=286160&browsefilter=mysubscriptions
and the broadcasting section of the script shows the pasted section below. I want to add something to make the rolled dice broadcast with a sum total at the end but I don't know what to add...
***********************************************************************************************
--Rolling
--Activates rolling process
function buttonClick_roll(_, rollerColor)
local dieOnPad = findDieOnPad()
if dieOnPad ~= nil then
if rollLock == false then
--Destroys old dice
buttonClick_clear(_, rollerColor)
--Spawns and rolls new nice
rollThisDieType(dieOnPad, rollerColor)
else
broadcastToColor("Please wait until the dice come to a complete stop before rolling again.", rollerColor, {1,1,1})
end
else
broadcastToColor("Place the die type you want to roll onto the pad and try again.", rollerColor, {1,1,1})
end
end
function rollThisDieType(dieOnPad, rollerColor)
function coroutine_rolling()
diceBeingRolled = {}
clearLock = true
rollLock = true
local angle = 360/howManyDice
for i=1, howManyDice do
local pos = findGlobalPosWithLocalDirection(self, distanceFromTool*self.getScale().x, angle*(i-1))
--Makes a duplicate of the die on the pad
local die = dieOnPad.clone({position=pos})
table.insert(diceBeingRolled, die)
--Gives it a random rotation and waits 1 frame for it to happen
die.setRotation(randomRotation())
coroutine.yield(0) coroutine.yield(0) coroutine.yield(0)
--Apply some rotational force in a random direction
--die.addTorque(randomRotation())
die.roll()
wait(0.05)
end
watchForDiceToStop(rollerColor)
return 1
end
startLuaCoroutine(self, "coroutine_rolling")
end
function watchForDiceToStop(rollerColor)
function coroutine_placing()
dieValueTable, rollString, totalRollValue = {}, "", 0
local angle = 360/howManyDice
local skillTest = 0
--Wait for dice to stop moving after their roll
for _, die in ipairs(diceBeingRolled) do
while die.resting == false do
coroutine.yield(0)
end
local rollValue = die.getValue()
local rollFace = die.getRotationValue()
totalRollValue = totalRollValue + rollValue
table.insert(dieValueTable, {die=die, val=rollValue, face=rollFace})
end
--Sort the dice by their .getValue() in ascending order
local sort_func = function(a,b) return a.val < b.val end
table.sort(dieValueTable, sort_func)
--Move the dice into order and/or prints
for i, entry in ipairs(dieValueTable) do
--Organizes dice
if organizeDice == true then
local pos = findGlobalPosWithLocalDirection(self, distanceFromTool*self.getScale().x, angle*(i-1))
pos.y = pos.y + 0.5
entry.die.setPositionSmooth(pos)
end
--Assembles print values
if i ~= 1 then rollString = rollString .. ", " end
rollString = rollString .. entry.face
end
if printResults == true then
broadcastToAll(Player[rollerColor].steam_name .. " rolled: " .. rollString, stringColorToRGB(rollerColor))
end
clearLock = false
rollLock = false
if autoCleanDelay ~= -1 then
Timer.create({
identifier="uniqueDelayName"..self.getGUID(),
delay=autoCleanDelay, function_owner=self, function_name="autoClearTimerFunction"
})
end
return 1
end
startLuaCoroutine(self, "coroutine_placing")
end
**********************************************************************************************
if printResults == true then
broadcastToAll(Player[rollerColor].steam_name .. " rolled: " .. rollString.."Total:".. totalRollValue, stringColorToRGB(rollerColor))
end