Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --If you set this to true it will add a table of fake players
- debugGame = false
- function onload()
- --startLuaCoroutine(Global, "boneFix") --Do not enable
- --startLuaCoroutine(Global, "setupBones") --Do not enable
- --Disables interactable status of objects with GUID in list
- for _, guid in ipairs(interactableList_off) do
- local obj = getObjectFromGUID(guid)
- if obj then obj.interactable = false end
- end
- bag_bones = getObjectFromGUID("4b725f")
- gameBoard = getObjectFromGUID("ef7e3c")
- deck_dino = getObjectFromGUID("5a37ec")
- deck_pale = getObjectFromGUID("c3e85e")
- paleToken = getObjectFromGUID("c0f732")
- local hiderButton = getObjectFromGUID("c282c9")
- if hiderButton ~= nil then
- hiderButton.reload()
- end
- spawnGameButtons()
- end
- --Game start setup
- --Button click to begin game
- function click_start(obj)
- function coroutine_click_start()
- local seatedPlayers = getSeatedPlayers()
- if debugGame == true then seatedPlayers = {"Red", "White", "Yellow", "Blue", "Green"} end
- if #seatedPlayers < 2 then
- broadcastToAll("This game requestes at least 2 players!", {0.9,0.1,0.1})
- else
- obj.clearButtons()
- local paleRandom = paleToken.getVar("paleRandom")
- obj.AssetBundle.playLoopingEffect(3)
- obj.AssetBundle.playTriggerEffect(1)
- --Shuffle Palentologists, dino cards, bone bag
- broadcastToAll("Shuffling Decks and Bone Bag", {1,1,1})
- if bag_bones ~= nil then bag_bones.shuffle() wait(0.5) end
- if deck_dino ~= nil then deck_dino.shuffle() wait(0.5) end
- destroyObject(obj)
- destroyObject(paleToken)
- if deck_pale ~= nil then deck_pale.shuffle() wait(0.5) end
- --Deal palentolgists
- broadcastToAll("Dealing Starting Items", {1,1,1})
- if paleRandom == true then
- --Random palentolgists
- for _, color in ipairs(seatedPlayers) do
- local pos = ref_paleCards[color].pos
- local rot = ref_paleCards[color].rot
- deck_pale.takeObject({position=pos, rotation=rot})
- wait(0.2)
- end
- else
- deck_pale.setPositionSmooth({-6.29, 1.8, 2.90})
- deck_pale.setRotationSmooth({0,0,180})
- end
- --Deal 2 dinosaur cards
- for _, color in ipairs(seatedPlayers) do
- deck_dino.deal(1, color)
- wait(0.15)
- deck_dino.deal(1, color)
- wait(0.25)
- end
- --Deal player bones
- for _, playerPad in ipairs(ref_playerBoneSpawn.pad) do
- for _, seatColor in ipairs(seatedPlayers) do
- if seatColor == playerPad.color then
- local pad = getObjectFromGUID(playerPad.guid)
- for i=1, 7 do
- local pos_local = ref_playerBoneSpawn.pos[i]
- local pos = pad.positionToWorld(pos_local)
- local rot = pad.getRotation()
- rot.y = rot.y + 90
- for _, bone in ipairs(bag_bones.getObjects()) do
- if bone.name == ref_playerBoneSpawn.type[i] then
- bag_bones.takeObject({
- position=pos,
- rotation=rot,
- guid=bone.guid
- })
- wait(0.05)
- break
- end
- end
- end
- end
- end
- end
- --Deal starting board bones
- broadcastToAll("Placing Bones in the World", {1,1,1})
- bag_bones.shuffle()
- wait(0.01)
- zOffset = 0.1
- rot = gameBoard.getRotation()
- if #seatedPlayers >= 4 then
- for _, pos_local in ipairs(ref_hexSpot_4) do
- pos_local[2] = pos_local[2]+0.06
- pos_local[3] = pos_local[3]-zOffset
- for i=1, 3 do
- local pos = gameBoard.positionToWorld(pos_local)
- bag_bones.takeObject({position=pos, rotation=rot})
- pos_local[3] = pos_local[3]+zOffset
- wait(0.05)
- end
- end
- end
- for _, pos_local in ipairs(ref_hexSpot_all) do
- pos_local[2] = pos_local[2]+0.06
- pos_local[3] = pos_local[3]-zOffset
- for i=1, 3 do
- local pos = gameBoard.positionToWorld(pos_local)
- bag_bones.takeObject({position=pos, rotation=rot})
- pos_local[3] = pos_local[3]+zOffset
- wait(0.05)
- end
- end
- if #seatedPlayers >= 5 then
- for _, pos_local in ipairs(ref_hexSpot_5) do
- pos_local[2] = pos_local[2]+0.06
- pos_local[3] = pos_local[3]-zOffset
- for i=1, 3 do
- local pos = gameBoard.positionToWorld(pos_local)
- bag_bones.takeObject({position=pos, rotation=rot})
- pos_local[3] = pos_local[3]+zOffset
- wait(0.05)
- end
- end
- end
- --Place score cube on track
- local scorePos = {-12.42, 1.43, -3.63}
- for _, color in ipairs(seatedPlayers) do
- if ref_scoreCubes[color] ~= nil then
- local cube = getObjectFromGUID(ref_scoreCubes[color])
- cube.setPositionSmooth(scorePos)
- scorePos[2] = scorePos[2] + 0.55
- end
- end
- wait(0.4)
- if paleRandom == true then
- broadcastToAll("Choose a first player and begin.", {1,1,1})
- else
- broadcastToAll("Choose paleontologists, pick a first player and begin.", {1,1,1})
- end
- end
- return 1
- end
- startLuaCoroutine(Global, "coroutine_click_start")
- end
- --Hidden zone manipulation
- --Button click to hide/reveal
- function click_hiddenMove(button, color)
- function coroutine_click_hiddenMove()
- if hide_lockout ~= true then
- hide_lockout = true
- local loopID = button.AssetBundle.getLoopingEffectIndex()
- if loopID == 1 then
- --Hide
- button.AssetBundle.playLoopingEffect(2)
- button.AssetBundle.playTriggerEffect(1)
- local hex = RGBToBracketedHex(stringColorToRGB(color))
- broadcastToAll(hex..Player[color].steam_name.."[-] has pressed [i]Hide[/i].", {1,1,1})
- for _, zoneGUID in ipairs(ref_hiddenZones) do
- local zone = getObjectFromGUID(zoneGUID)
- local pos = zone.getPosition()
- zone.setPositionSmooth({pos.x,3.50,pos.z})
- wait(0.15)
- end
- elseif loopID == 2 then
- --Show
- button.AssetBundle.playLoopingEffect(1)
- button.AssetBundle.playTriggerEffect(1)
- local hex = RGBToBracketedHex(stringColorToRGB(color))
- broadcastToAll(hex..Player[color].steam_name.."[-] has pressed [i]Show[/i].", {1,1,1})
- for _, zoneGUID in ipairs(ref_hiddenZones) do
- local zone = getObjectFromGUID(zoneGUID)
- local pos = zone.getPosition()
- zone.setPositionSmooth({pos.x,-5,pos.z})
- wait(0.15)
- end
- end
- wait(0.2)
- hide_lockout = false
- end
- return 1
- end
- startLuaCoroutine(Global, "coroutine_click_hiddenMove")
- end
- --Utility functions
- --Coroutine delay, in seconds
- function wait(time)
- local start = os.time()
- repeat coroutine.yield(0) until os.time() > start + time
- end
- --Converts an RGB table into bracketed hex (bb font coloring)
- function RGBToBracketedHex(rgb)
- if rgb ~= nil then
- return "[" .. string.format("%02x%02x%02x", rgb.r*255,rgb.g*255,rgb.b*255) .. "]"
- else
- return ""
- end
- end
- --Button creation
- function spawnGameButtons()
- --Fog-hider button
- button_showHide = getObjectFromGUID("c282c9")
- if button_showHide ~= nil then
- button_showHide.createButton({
- click_function="click_hiddenMove", function_owner=Global,
- position={0,1,0}, rotation={0,0,0}, height=1500, width=1500
- })
- end
- --Start button
- button_start = getObjectFromGUID("faafaa")
- if button_start ~= nil then
- button_start.createButton({
- click_function="click_start", function_owner=Global,
- position={0,1,0}, rotation={0,0,0}, height=1500, width=1500
- })
- end
- end
- --Data tables
- --Items non-interactable (by guid)
- interactableList_off = {
- "0d2505",
- }
- --Hidden zones (fogOfWarTrigger) (by guid)
- ref_hiddenZones = {
- "405ca1", "3962c7", "775c85", "c6f89d", "066fa5",
- }
- --For giving players their starting bones
- ref_playerBoneSpawn = {
- pad = {
- {guid="f3d98a", color="Red"},
- {guid="a70fe4", color="White"},
- {guid="79ae07", color="Yellow"},
- {guid="6d1aaa", color="Blue"},
- {guid="7b3f40", color="Green"},
- },
- pos = {
- {0.407, 0.083, -0.073}, {0.14, 0.085, -0.09},
- {-0.151, 0.089, -0.073}, {-0.45, 0.076, -0.086},
- {0.267, 0.093, 0.11}, {-0.022, 0.088, 0.113}, {-0.299, 0.083, 0.106}
- },
- type = {
- "Red Bone", "Red Bone", "Yellow Bone", "Yellow Bone",
- "Green Bone", "Green Bone", "Green Bone"
- }
- }
- --For placing bones onto the board (for all game types, 1 row per line)
- ref_hexSpot_all = {
- {1.711, 0.1, 0.001}, {0.852, 0.1, 0}, {-0.868, 0.1, -0.001}, {-1.727, 0.1, -0.001},
- {1.281, 0.1, 0.745}, {-0.438, 0.1, 0.744}, {-1.298, 0.1, 0.743},
- {1.711, 0.1, 1.489}, {0.851, 0.1, 1.489}, {-0.009, 0.1, 1.489}, {-0.868, 0.1, 1.488}, {-1.728, 0.1, 1.488},
- {1.28, 0.1, 2.234}, {0.421, 0.1, 2.233}, {-1.298, 0.1, 2.232},
- {1.71, 0.1, 2.978}, {-0.009, 0.1, 2.977}, {-0.869, 0.1, 2.977}, {-1.729, 0.1, 2.977},
- }
- --For placing more bones onto the board (for games of 4 or 5)
- ref_hexSpot_4 = {
- {1.282, 0.1, -0.744}, {0.422, 0.1, -0.745},
- {-0.437, 0.1, -0.745}, {-1.297, 0.1, -0.745}
- }
- --For placing more bones onto the board (for games of 5)
- ref_hexSpot_5 = {
- {1.28, 0.1, 3.723}, {0.42, 0.1, 3.722},
- {-0.44, 0.1, 3.722}, {-1.299, 0.1, 3.721},
- }
- ref_scoreCubes = {
- ["Red"] = "21caf4",
- ["White"] = "9f3a83",
- ["Yellow"] = "1641f8",
- ["Blue"] = "af0766",
- ["Green"] = "64520e",
- }
- ref_paleCards = {
- ["Red"] = {pos={0.49, 0.70, -12.94}, rot={0,90,0}},
- ["White"] = {pos={20.66, 0.70, -13.06}, rot={0,90,0}},
- ["Yellow"] = {pos={20.58, 0.70, 8.15}, rot={0,180,0}},
- ["Blue"] = {pos={10.51, 0.70, 17.48}, rot={0,270,0}},
- ["Green"] = {pos={-10.45, 0.70, 17.37}, rot={0,270,0}},
- }
- --[[ This function was only used to remove sticky and tooltip from bones.
- function boneFix()
- local bag = getObjectFromGUID("4b725f")
- local theBones = {}
- for _, bone in ipairs(bag.getObjects()) do
- local spawnedBone = bag.takeObject({position={0,10,0}})
- wait(0.01)
- spawnedBone.setLock(true)
- spawnedBone.sticky = false
- spawnedBone.tooltip = false
- table.insert(theBones, spawnedBone)
- end
- wait(2)
- for _, bone in ipairs(theBones) do
- bone.setLock(false)
- bag.putObject(bone)
- wait(0.01)
- end
- return 1
- end
- --Round number (num) to the Nth decimal (dec)
- function round(num, dec)
- local mult = 10^(dec or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- ]]
- --[[ This function was used to find the centerpoint of each (valid) grid space
- function setupBones()
- while true do
- gameBoard = getObjectFromGUID("ef7e3c")
- setupTile = getObjectFromGUID("0f4cc2")
- local pos = gameBoard.positionToLocal(setupTile.getPosition())
- setNotes("{"..round(pos.x,3)..", "..round(pos.y,3)..", "..round(pos.z,3).."}, ")
- wait(0.5)
- end
- return 1
- end
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement