Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onLoad()
- --Game board
- gameBoardGUID = '0ed963'
- gameBoardObj = getObjectFromGUID(gameBoardGUID)
- --Game box
- gameBoxGUID = '144d41'
- gameBoxObj = getObjectFromGUID(gameBoxGUID)
- --infinte cube bag
- cubeBagGUID = '35f952'
- cubeBagObj = getObjectFromGUID(cubeBagGUID)
- --3D Hex bags
- levelOneRoomGUID = '069477'
- levelTwoRoomGUID = '32cb67'
- levelOneRoomObj = getObjectFromGUID(levelOneRoomGUID)
- levelTwoRoomObj = getObjectFromGUID(levelTwoRoomGUID)
- exploreTokenBagGUID = 'f736bf'
- exploreTokenBagObj = getObjectFromGUID(exploreTokenBagGUID)
- intruderadultBagGUID = 'f6237f' --soon to be hex bag
- intruderyoungBagGUID = '1c3892' --soon to be hex bag
- intruderlarvaBagGUID = '1dfe74' --soon to be hex bag
- intruderadultBagObj = getObjectFromGUID(intruderadultBagGUID)
- intrudersBagGUID = 'be3b6a'
- intrudersBagObj = getObjectFromGUID(intrudersBagGUID)
- --Turn Order Cards/Deck
- turnOrderOneCardGUID = '4f75a5'
- turnOrderTwoCardGUID = 'ce2e5b'
- turnOrderThreeCardGUID = 'e2599f'
- turnOrderFourCardGUID = '348fc2'
- turnOrderFiveCardGUID = '2b9c1f'
- turnOrderBagGUID = '4707b0'
- turnOrderBag = getObjectFromGUID(turnOrderBagGUID)
- --Primary Objective Player Count Cards/Deck
- primaryObjective2PCardGUIDsTable = {'f52fae', '267c36', '8f566a'}
- primaryObjective3PCardGUIDsTable = {'a84897', 'de8581', '0a9166'}
- primaryObjective4PCardGUIDsTable = {'6082bd', '6c009a'}
- primaryObjective5PCardGUIDsTable = {'ca9f96'}
- primaryObjectivesZoneGUID = '547716'
- primaryObjectivesDeckGUID = getDeckGUID(primaryObjectivesZoneGUID)--'6ee332'
- primaryObjectivesDeck = getObjectFromGUID(primaryObjectivesDeckGUID)
- --Card Decks
- contaminationDeckZoneGUID = '23efb6'
- --Must be declaired for shuffle timer
- contaminationDeckZone = getObjectFromGUID(contaminationDeckZoneGUID)
- contaminationDeckGUID = getDeckGUID(contaminationDeckZoneGUID)
- contaminationDeck = getObjectFromGUID(contaminationDeckGUID)
- panicZoneGUID = '5793fe'
- panicDeckGUID = getDeckGUID(panicZoneGUID)--'9dd4fa'
- panicDeck = getObjectFromGUID(panicDeckGUID)
- intruderAttackZoneGUID= '82d5bc'
- intruderAttackDeckGUID = getDeckGUID(intruderAttackZoneGUID)--'2d45fa'
- intruderAttackDeck = getObjectFromGUID(intruderAttackDeckGUID)
- seriousWoundZoneGUID = '624f56'
- seriousWoundDeckGUID = getDeckGUID(seriousWoundZoneGUID)--d'1d28ca'
- seriousWoundDeck = getObjectFromGUID(seriousWoundDeckGUID)
- altObjectiveZoneGUID = '8de77a'
- altObjectiveDeckGUID = getDeckGUID(altObjectiveZoneGUID)--'c12e82'
- altObjectiveDeck = getObjectFromGUID(altObjectiveDeckGUID)
- eventZoneGUID = '3e087d'
- eventDeckGUID = getDeckGUID(eventZoneGUID) -- '58cc16'
- eventDeck = getObjectFromGUID(eventDeckGUID)
- intruderWeakZoneGUID = '3cb4c1'
- intruderWeakDeckGUID = getDeckGUID(intruderWeakZoneGUID) --'d489b8'
- intruderWeakDeck = getObjectFromGUID(intruderWeakDeckGUID)
- coordinateZoneGUID = '86e9e9'
- coordinateDeckGUID = getDeckGUID(coordinateZoneGUID)--'363b4a'
- coordinateDeck= getObjectFromGUID(coordinateDeckGUID)
- engineZoneOneGUID = '2e0815'
- engineZoneTwoGUID = '9b1dd5'
- engineZoneThreeGUID = '0992b1'
- engineOneGUID = getDeckGUID(engineZoneOneGUID)
- engineTwoGUID = getDeckGUID(engineZoneTwoGUID)
- engineThreeGUID = getDeckGUID(engineZoneThreeGUID)
- engineOneDeck = getObjectFromGUID(engineOneGUID)
- engineTwoDeck = getObjectFromGUID(engineTwoGUID)
- engineThreeDeck = getObjectFromGUID(engineThreeGUID)
- equipmentGreenZoneGUID = 'b52876'
- equipmentRedZoneGUID = '2ef465'
- equipmentYellowZoneGUID = 'f6a09b'
- equipmentGreenDeckGUID = getDeckGUID(equipmentGreenZoneGUID)--'467a07'
- equipmentRedDeckGUID = getDeckGUID(equipmentRedZoneGUID)--'73f74d'
- equipmentYellowDeckGUID = getDeckGUID(equipmentYellowZoneGUID)--'4c94e8'
- equipmentGreenDeck = getObjectFromGUID(equipmentGreenDeckGUID)
- equipmentRedDeck = getObjectFromGUID(equipmentRedDeckGUID)
- equipmentYellowDeck = getObjectFromGUID(equipmentYellowDeckGUID)
- --Escape Pod tokens
- escapePodThreeGUID = 'd62a18'
- escapePodFourGUID = 'e57f0e'
- --AR Logo Token. Used to prevent game setup from loading when it's missing during back up history
- --For now this has been converted to The Beard
- arLogoTokenGUID = '1c663a'
- arLogoToken = getObjectFromGUID(arLogoTokenGUID)
- --player mat assests
- playerMat01GUID = 'c5eb18'
- playerMat01 = getObjectFromGUID(playerMat01GUID)
- playerMat01ZoneGUID = '30c8b4'
- playerMat02GUID = 'b89552'
- playerMat02 = getObjectFromGUID(playerMat02GUID)
- playerMat02ZoneGUID = '6f9266'
- playerMat03GUID = 'beb6c6'
- playerMat03 = getObjectFromGUID(playerMat03GUID)
- playerMat03ZoneGUID = '541ad0'
- playerMat04GUID = '777b28'
- playerMat04 = getObjectFromGUID(playerMat04GUID)
- playerMat04ZoneGUID = 'f56f2a'
- playerMat05GUID = '1ea963'
- playerMat05 = getObjectFromGUID(playerMat05GUID)
- playerMat05ZoneGUID = 'e28056'
- playerMatTable = {playerMat01,playerMat02,playerMat03,playerMat04,playerMat05,}
- playerMatZoneGUIDTable = {playerMat01ZoneGUID, playerMat02ZoneGUID, playerMat03ZoneGUID, playerMat04ZoneGUID, playerMat05ZoneGUID}
- --Crew Members game pieces
- captainPlayMatGUID = '174ff9'
- captainFigureGUID = '369dfb'
- captainEquip01ZoneGUID = '839806'
- captainEquip02ZoneGUID = '24867a'
- captainEquip01GUID = getDeckGUID(captainEquip01ZoneGUID)
- captainEquip02GUID = getDeckGUID(captainEquip02ZoneGUID)
- captinDeckZoneGUID = '23f141'
- captainDeckGUID = getDeckGUID(captinDeckZoneGUID)
- captainDeck = getObjectFromGUID(captainDeckGUID)
- pilotPlayMatGUID = 'f59473'
- pilotFigureGUID = '6c38c1'
- pilotEquip01ZoneGUID = '22f0c8'
- pilotEquip02ZoneGUID = '69b4c3'
- pilotEquip01GUID = getDeckGUID(pilotEquip01ZoneGUID)
- pilotEquip02GUID = getDeckGUID(pilotEquip02ZoneGUID)
- pilotDeckZoneGUID = '92607f'
- pilotDeckGUID = getDeckGUID(pilotDeckZoneGUID)
- pilotDeck = getObjectFromGUID(pilotDeckGUID)
- scientistPlayMatGUID = 'ae9dd5'
- scientistFigureGUID = '688a9c'
- scientistEquip01ZoneGUID = 'a048ac'
- scientistEquip02ZoneGUID = '6b3cec'
- scientistEquip01GUID = getDeckGUID(scientistEquip01ZoneGUID)
- scientistEquip02GUID = getDeckGUID(scientistEquip02ZoneGUID)
- scientistDeckZoneGUID = 'e96177'
- scientistDeckGUID = getDeckGUID(scientistDeckZoneGUID)
- scientistDeck = getObjectFromGUID(scientistDeckGUID)
- scoutPlayMatGUID = '2bcc1b'
- scoutFigureGUID = 'bdedbb'
- scoutEquip01ZoneGUID = '47ff90'
- scoutEquip02ZoneGUID = '38af5a'
- scoutEquip01GUID = getDeckGUID(scoutEquip01ZoneGUID)
- scoutEquip02GUID = getDeckGUID(scoutEquip02ZoneGUID)
- scoutDeckZoneGUID = '57d901'
- scoutDeckGUID = getDeckGUID(scoutDeckZoneGUID)
- scoutDeck = getObjectFromGUID(scoutDeckGUID)
- soldierPlayMatGUID = 'c80252'
- soldierFigureGUID = '366347'
- soldierEquip01ZoneGUID = '77e208'
- soldierEquip02ZoneGUID = 'e5706a'
- soldierEquip01GUID = getDeckGUID(soldierEquip01ZoneGUID)
- soldierEquip02GUID = getDeckGUID(soldierEquip02ZoneGUID)
- soldierDeckZoneGUID = '5683ef'
- soldierDeckGUID = getDeckGUID(soldierDeckZoneGUID)
- soldierDeck = getObjectFromGUID(soldierDeckGUID)
- mechanicPlayMatGUID = 'e510d6'
- mechanicFigureGUID = '007c84'
- mechanicEquip01ZoneGUID = 'c4d87c'
- mechanicEquip02ZoneGUID = '8ef9e5'
- mechanicEquip01GUID = getDeckGUID(mechanicEquip01ZoneGUID)
- mechanicEquip02GUID = getDeckGUID(mechanicEquip02ZoneGUID)
- mechanicDeckZoneGUID = '4f1b0f'
- mechanicDeckGUID = getDeckGUID(mechanicDeckZoneGUID)
- mechanicDeck = getObjectFromGUID(mechanicDeckGUID)
- medicPlayMatGUID = '8f2474'
- medicFigureGUID = 'da5a93'
- medicEquip01ZoneGUID = '92433e'
- medicEquip02ZoneGUID = '88b94a'
- medicEquip01GUID = getDeckGUID(medicEquip01ZoneGUID)
- medicEquip02GUID = getDeckGUID(medicEquip02ZoneGUID)
- medicDeckZoneGUID = '0e0932'
- medicDeckGUID = getDeckGUID(medicDeckZoneGUID)
- medicDeck = getObjectFromGUID(medicDeckGUID)
- crewMatTable = {captainPlayMatGUID,pilotPlayMatGUID,scientistPlayMatGUID,scoutPlayMatGUID,
- soldierPlayMatGUID,mechanicPlayMatGUID,medicPlayMatGUID}
- --Call the functoin to build the equipment list and positions table
- buildCrewsEquipmentTable()
- --Call the functoin to build the position table
- buildPositionsTable()
- --AR Logo Token. Used to prevent game setup from loading when it's missing during back up history
- --For now this has been converted to The Beard
- arLogoTokenGUID = '1c663a'
- arLogoToken = getObjectFromGUID(arLogoTokenGUID)
- --Checks to see if the automated game set up has run. If not it will start it.
- --It will will only run if the AR arLogoToken is out on the table.
- --Once it's done it will remove to token to prevent this script from running again.
- if arLogoToken ~= nil then
- --Creates the button to call board setup function
- gameBoardObj.createButton(
- {click_function='setupFullGame', function_owner=Global, label='Full Setup',
- position={0.2,1.5,0}, rotation={0,0,0}, width=675, height=225, font_size=100,
- scale={0.4,0.4,0.4}, tooltip='Completely Automated Setup'}
- )
- gameBoardObj.createButton(
- {click_function='setupGameBoard', function_owner=Global, label='Board Only',
- position={0.055,1.5,0.15}, rotation={0,0,0}, width=600, height=225, font_size=100,
- scale={0.2,0.2,0.2}, tooltip='Rooms & Exploration Tokens only'}
- )
- gameBoardObj.createButton(
- {click_function='skipSetup', function_owner=Global, label='Skip',
- position={0.34,1.5,0.15}, rotation={0,0,0}, width=600, height=225, font_size=100,
- scale={0.2,0.2,0.2}, tooltip='Manual Setup'}
- )
- --Delete later
- gameBoardObj.createButton(
- {click_function='newStuff', function_owner=Global, label='New Rooms &\n Explore Tokens',
- position={0.8,1.5,0}, rotation={0,0,0}, width=675, height=225, font_size=90,
- scale={0.4,0.4,0.4}, tooltip='Click to use new rooms and tokens for the game setup.'}
- )
- --note = 'Thank you for playing Nemesis \n Get the rules on the TTS workshop page \n \nTo begin, select a setup option.'
- --note = note .. '\n \n Join our AR/TTS Discord - Talk about the game or find other players. https://discord.gg/Ncu7ny3\n'
- note = '\n \n Join our AR/TTS LFG Discord - Talk about the game or find other players. https://discord.gg/Ncu7ny3\n\n'
- note = note .. 'You can find the updated content in the large bag on the top right corner of the table. Feel free to try and mix it into the game.\n\n'
- note = note .. 'I am going to wait for AR to release the new rulebook before officially updating the mod.'
- setNotes(note)
- --Shuffles eveything on the table that needs to be random
- shuffleEverything()
- else
- note = '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
- note = note .. 'Any rule question? \n\n'
- note = note .. '- Check FAQ: https://goo.gl/ybd5qE \n\n'
- note = note .. '- Answer not found, ask here: https://goo.gl/DJf4cV \n\n'
- setNotes(note)
- end
- --Creates a Timer to shuffle the intruder bag if its contents change.
- Timer.create({
- identifier = 'shuffleCheckTimer',
- function_name = 'shuffleCheck',
- function_owner = self,
- delay = 1,
- repetitions = 0,
- })
- end
- --this function is sent a GUID for a script zone and it will return the GUID
- --for the deck or card found in that zone.
- function getDeckGUID(zoneGUID)
- deckZone = getObjectFromGUID(zoneGUID)
- objInZone = deckZone.getObjects()
- if #objInZone == 1 then
- deckGUID = objInZone[1].getGUID()
- return deckGUID
- else
- if arLogoToken ~= nil then
- string = 'Zone GUID ' .. tostring(zoneGUID) .. ' is empty or has more then one object'
- broadcastToAll(string, red)
- end
- end
- end
- --This function is tempoary -- It will declaire the new bags as the bags to pull from.
- function newStuff()
- levelOneRoomGUID = '0c9ec4'
- levelTwoRoomGUID = '766516'
- levelOneRoomObj = getObjectFromGUID(levelOneRoomGUID)
- levelTwoRoomObj = getObjectFromGUID(levelTwoRoomGUID)
- exploreTokenBagGUID = '9e104a'
- exploreTokenBagObj = getObjectFromGUID(exploreTokenBagGUID)
- Wait.time(setupFullGame, 1)
- end
- function setupFullGame()
- setupGameBoard()
- Timer.create({
- identifier = 'playerCountTimer',
- function_name = 'getPlayerCount',
- function_owner = self,
- delay = 0.5,
- })
- end
- function setupGameBoard()
- --Clears the buttons from the game board
- gameBoardObj.clearButtons()
- --Puts the Beard in the box to prevent onload functoin from starting initial setup
- gameBoxObj.putObject(arLogoToken)
- --Loop to pull room tiles from the bag and place them on the board
- for _, entries in ipairs(gamePiecePosTable) do
- --pulls the object from each Room container and places them on the board
- entries.objToPullFrom.takeObject({
- position = entries.pos_object,
- rotation = entries.rot_object,
- })
- end
- end
- function shuffleEverything()
- thingsToShuffle = {
- --decks - starting from top left and around clockwise
- coordinateDeck,
- contaminationDeck,
- panicDeck,
- intruderAttackDeck,
- seriousWoundDeck,
- altObjectiveDeck,
- eventDeck,
- intruderWeakDeck,
- primaryObjectivesDeck,
- engineOneDeck, engineTwoDeck, engineThreeDeck,
- soldierDeck, scoutDeck, scientistDeck, pilotDeck, captainDeck,mechanicDeck,medicDeck,
- equipmentGreenDeck, equipmentRedDeck, equipmentYellowDeck,
- --bags
- levelOneRoomObj, levelTwoRoomObj,
- exploreTokenBagObj,
- turnOrderBag,
- intrudersBagObj,
- }
- for _, entries in ipairs(thingsToShuffle) do
- entries.shuffle()
- end
- end
- function getPlayerCount()
- gameBoardObj.createButton(
- {click_function='none', function_owner=Global, label='How Many Players?',
- position={0.2,1.5,0}, rotation={0,0,0}, width=900, height=225, font_size=100,
- scale={0.4,0.4,0.4}}
- )
- gameBoardObj.createButton(
- {click_function='onePlayerClick', function_owner=Global, label='1',
- position={-0.1,1.5,0.15}, rotation={0,0,0}, width=300, height=225, font_size=100,
- scale={0.2,0.2,0.2}}
- )
- gameBoardObj.createButton(
- {click_function='twoPlayerClick', function_owner=Global, label='2',
- position={0.05,1.5,0.15}, rotation={0,0,0}, width=300, height=225, font_size=100,
- scale={0.2,0.2,0.2}}
- )
- gameBoardObj.createButton(
- {click_function='threePlayerClick', function_owner=Global, label='3',
- position={0.2,1.5,0.15}, rotation={0,0,0}, width=300, height=225, font_size=100,
- scale={0.2,0.2,0.2}}
- )
- gameBoardObj.createButton(
- {click_function='fourPlayerClick', function_owner=Global, label='4',
- position={0.35,1.5,0.15}, rotation={0,0,0}, width=300, height=225, font_size=100,
- scale={0.2,0.2,0.2}}
- )
- gameBoardObj.createButton(
- {click_function='fivePlayerClick', function_owner=Global, label='5',
- position={0.5,1.5,0.15}, rotation={0,0,0}, width=300, height=225, font_size=100,
- scale={0.2,0.2,0.2}}
- )
- note = 'Select the number of players. \n \n If more people join after this point you will need to reload the mod.'
- setNotes(note)
- end
- function onePlayerClick()
- playerCount = 1
- allPlayersSeatedCheck()
- end
- function twoPlayerClick()
- playerCount = 2
- allPlayersSeatedCheck()
- end
- function threePlayerClick()
- playerCount = 3
- allPlayersSeatedCheck()
- end
- function fourPlayerClick()
- playerCount = 4
- allPlayersSeatedCheck()
- end
- function fivePlayerClick()
- playerCount = 5
- allPlayersSeatedCheck()
- end
- function allPlayersSeatedCheck()
- if #getSeatedPlayers() == playerCount then
- playerSetup()
- else
- gameBoardObj.clearButtons()
- gameBoardObj.createButton(
- {click_function='playerSetup', function_owner=Global, label='Continue',
- position={0.2,1.5,0}, rotation={0,0,0}, width=900, height=225, font_size=100,
- scale={0.4,0.4,0.4}}
- )
- broadcastToAll('Players not in a seat will have to draw manually. \n Make sure eveyone is seated', {0.956, 0.392, 0.113})
- end
- end
- function playerSetup()
- gameBoardObj.clearButtons()
- --This will remove a random Crew memeber from the table.
- if playerCount ~= 5 then
- crewNameTable = {'Captain','Pilot','Scientist','Scout','Soldier','Mechanic','Medic'}
- stuffToClearTable = {
- --Captain's stuff table
- {captainPlayMatGUID, captainFigureGUID, captainDeckGUID,captainEquip01GUID,captainEquip02GUID},
- --Pilots stuff table
- {pilotPlayMatGUID, pilotFigureGUID, pilotDeckGUID,pilotEquip01GUID,pilotEquip02GUID},
- --Scientist's stuff table
- {scientistPlayMatGUID, scientistFigureGUID, scientistDeckGUID,scientistEquip01GUID,scientistEquip02GUID},
- --Scout's stuff table
- {scoutPlayMatGUID, scoutFigureGUID, scoutDeckGUID,scoutEquip01GUID,scoutEquip02GUID},
- --Soldier's stuff table
- {soldierPlayMatGUID, soldierFigureGUID, soldierDeckGUID,soldierEquip01GUID,soldierEquip02GUID},
- --Mechanic's stuff table
- {mechanicPlayMatGUID, mechanicFigureGUID, mechanicDeckGUID,mechanicEquip01GUID,mechanicEquip02GUID},
- --Soldier's stuff table
- {medicPlayMatGUID, medicFigureGUID, medicDeckGUID,medicEquip01GUID,medicEquip02GUID},
- }
- crewToKill = math.random(1,5)
- for _, obj_GUID in ipairs(stuffToClearTable[crewToKill]) do
- obj = getObjectFromGUID(obj_GUID)
- gameBoxObj.putObject(obj)
- end
- message = 'The ' .. crewNameTable[crewToKill] .. ' has been found dead!'
- broadcastToAll(message, {0.905, 0.898, 0.172})
- end
- --This function will remove all game pieces not valild for the current player count
- removeUnusedGamePieces()
- --Checks again for all playes seat incase there was a change.
- playersInSeatTable = getSeatedPlayers()
- aboveIntruderBag = intrudersBagObj.getPosition()
- for i, entries in ipairs(playersInSeatTable) do
- turnOrderBag.deal(1, entries, int)
- primaryObjectivesDeck.deal(2, entries, int)
- --Adds one adult intruder for that playerCount
- aboveIntruderBag.y = aboveIntruderBag.y+1
- intruderadultBagObj.takeObject({
- position = aboveIntruderBag,
- })
- if i == playerCount then break end
- i = i + 1
- end
- --Creates the button to call board setup function
- gameBoardObj.createButton(
- {click_function='playersReadyCheck', function_owner=Global, label='Begin Game',
- position={0.2,1.5,0}, rotation={0,0,0}, width=675, height=225, font_size=100,
- scale={0.4,0.4,0.4}}
- )
- gameBoardObj.createButton(
- {click_function='skipSetup', function_owner=Global, label='Skip',
- position={0.34,1.5,0.15}, rotation={0,0,0}, width=600, height=225, font_size=100,
- scale={0.2,0.2,0.2}}
- )
- note = 'Each player will need to select a Crew Member.\n\n'
- note = note .. 'Once everyone is ready select Begin Game. \n\n\n\n'
- note = note .. 'Thank you for choosing Nemesis and Fly Safe.'
- setNotes(note)
- Timer.create({
- identifier = 'buildCrewButtons',
- function_name = 'buildCrewPickButtons',
- function_owner = self,
- delay = 0.5,
- })
- end
- function playersReadyCheck()
- selectCrewCount = 0
- for _, matGUID in ipairs(crewMatTable) do
- obj = getObjectFromGUID(matGUID)
- if obj ~= nil then
- if obj.getLock() == true then
- selectCrewCount = selectCrewCount + 1
- end
- end
- end
- if playerCount <= selectCrewCount then
- finalSetupStep()
- else
- broadcastToAll('Each Player needs to select a Crew Member.\n Press Begin Game when ready.', {0.905, 0.898, 0.172})
- end
- end
- function buildCrewPickButtons()
- buttonsParametersTable = {
- {playMatGUID = captainPlayMatGUID, click_function = 'pickCaptain', label = 'Captain', position = {0.0,0.3,-0.3}},
- {playMatGUID = pilotPlayMatGUID, click_function = 'pickPilot', label = 'Pilot', position = {0.0,0.3,-0.15}},
- {playMatGUID = scientistPlayMatGUID, click_function = 'pickScientist', label = 'Scientist', position = {0.0,0.3,0.0}},
- {playMatGUID = scoutPlayMatGUID, click_function = 'pickScout', label = 'Scout', position = {0.0,0.3,0.15}},
- {playMatGUID = soldierPlayMatGUID, click_function = 'pickSoldier', label = 'Soldier', position = {0.45,0.3,-0.3}},
- {playMatGUID = mechanicPlayMatGUID, click_function = 'pickMechanic', label = 'Mechanic', position = {0.45,0.3,-0.15}},
- {playMatGUID = medicPlayMatGUID, click_function = 'pickMedic', label = 'Medic', position = {0.45,0.3,0.0}},
- }
- for _, obj in ipairs(playerMatTable) do
- for _, entries in ipairs(buttonsParametersTable) do
- stillAlive = getObjectFromGUID(entries.playMatGUID)
- if stillAlive ~= nil then
- obj.createButton({
- click_function = entries.click_function,
- function_owner = obj,
- label = entries.label,
- position = entries.position,
- scale = {0.4,0.4,0.4},
- width = 500,
- height = 160,
- font_size = 100,
- })
- else
- obj.createButton({
- click_function = 'crewNotAvailable',
- function_owner = Global,
- label = '',
- position = entries.position,
- scale = {0.4,0.4,0.4},
- width = 500,
- height = 160,
- font_size = 100,
- })
- end
- end
- end
- end
- function crewNotAvailable()
- broadcastToAll('Sorry this crew member is not available', {0.956, 0.392, 0.113})
- end
- function pickCrewMember(passTable)
- --Table index 1 is playerMatGUID -passTable[1]
- --Table index 2 is crewMemberIndex - passTable[2]
- playerMatGUID = passTable[1]
- centerPos = getObjectFromGUID(playerMatGUID).getPosition()
- crewMemberSelectedGUID = crewMatTable[passTable[2]]
- crewMemberSelected = getObjectFromGUID(crewMemberSelectedGUID)
- posX = centerPos[1] + 2.75
- posY = centerPos[2] + 0.05
- posZ = centerPos[3] + 0.65
- crewMemberSelected.setPosition({posX, posY , posZ})
- getObjectFromGUID(playerMatGUID).clearButtons()
- --this loop will remove the buttons for the sleceted crew from the other boards.
- buttonIndex = passTable[2] - 1
- for _, playMat in ipairs(playerMatTable) do
- if playMat.getButtons() ~= nil then
- playMat.editButton({
- index = buttonIndex,
- click_function = 'crewNotAvailable',
- function_owner = Global,
- label = '',
- })
- end
- end
- end
- function onObjectEnterScriptingZone(zone, enter_object)
- if enter_object.getDescription() == 'Crew Member' then
- zoneGUID = zone.getGUID()
- if zoneGUID == playerMat01ZoneGUID then
- posCenter = playerMat01.getPosition()
- placeCrewMember(1,enter_object,posCenter,zone)
- else
- if zoneGUID == playerMat02ZoneGUID then
- posCenter = playerMat02.getPosition()
- placeCrewMember(2,enter_object,posCenter,zone)
- else
- if zoneGUID == playerMat03ZoneGUID then
- posCenter = playerMat03.getPosition()
- placeCrewMember(3,enter_object,posCenter,zone)
- else
- if zoneGUID == playerMat04ZoneGUID then
- posCenter = playerMat04.getPosition()
- placeCrewMember(4,enter_object,posCenter,zone)
- else
- if zoneGUID == playerMat05ZoneGUID then
- posCenter = playerMat05.getPosition()
- placeCrewMember(5,enter_object,posCenter,zone)
- end
- end
- end
- end
- end
- end
- end
- function placeCrewMember(playerNumber,enter_object,posCenter,zone)
- findCrewsEquipTable = {
- {matGUID = captainPlayMatGUID, equipTable = captainEquipList, cubePosTable = captainCubeTable, figureGUID = captainFigureGUID},
- {matGUID = pilotPlayMatGUID, equipTable = pilotEquipList, cubePosTable = pilotCubeTable, figureGUID = pilotFigureGUID},
- {matGUID = scientistPlayMatGUID, equipTable = scientistEquipList, cubePosTable = scientistCubeTable, figureGUID = scientistFigureGUID},
- {matGUID = scoutPlayMatGUID, equipTable = scoutEquipList, cubePosTable = scoutCubeTable, figureGUID = scoutFigureGUID},
- {matGUID = soldierPlayMatGUID, equipTable = soldierEquipList, cubePosTable = soldierCubeTable, figureGUID = soldierFigureGUID},
- {matGUID = mechanicPlayMatGUID, equipTable = mechanicEquipList, cubePosTable = mechanicCubeTable, figureGUID = mechanicFigureGUID},
- {matGUID = medicPlayMatGUID, equipTable = medicEquipList, cubePosTable = medicCubeTable, figureGUID = medicFigureGUID},
- }
- zone.destruct()
- for _, entries in pairs(findCrewsEquipTable) do
- --find the selected crew memebers equipment lists
- if enter_object.getGUID() == entries.matGUID then
- crewEquipTable = entries.equipTable
- cubesToSpawnPosTable = entries.cubePosTable
- figureToPlaceGUID = entries.figureGUID
- end
- end
- enter_object.setLock(true)
- enter_object.setDescription('Keep')
- --places the figure on the board acording to player position
- figurePosTable = {{3.80, 2.01, 0.05},{5.13, 2.02, -1.50},{5.09, 2.03, 1.65},{3.40, 2.04, -3.37},{3.93, 2.05, 3.65}}
- selctedCrewFigureObj = getObjectFromGUID(figureToPlaceGUID)
- selctedCrewFigureObj.setPosition(figurePosTable[playerNumber])
- --Place crew members equipment cards on the selected mat
- for _, entries in ipairs(crewEquipTable) do
- obj = getObjectFromGUID(entries.objGUID)
- posX = posCenter[1] + entries.pos[1]
- posZ = posCenter[3] + entries.pos[3]
- obj.setPosition({ posX , 1.8 , posZ })
- end
- --places the cubes needed for the selected crew memebers
- for _, entries in ipairs(cubesToSpawnPosTable) do
- posX = posCenter[1] + entries[1]
- posZ = posCenter[3] + entries[3]
- cubeBagObj.takeObject({ position = { posX , 2.0 , posZ },})
- end
- end
- function removeUnusedGamePieces()
- --Removes itmes not valid for current player count.
- aboveGameBox = gameBoxObj.getPosition()
- aboveGameBox.y = aboveGameBox.y+6
- if playerCount <= 4 then
- turnOrderBag.takeObject({
- position = aboveGameBox,
- guid = turnOrderFiveCardGUID,
- })
- aboveGameBox.y = aboveGameBox.y+2
- for _, entries in ipairs(primaryObjective5PCardGUIDsTable) do
- primaryObjectivesDeck.takeObject({
- position = aboveGameBox,
- guid = entries,
- })
- aboveGameBox.y = aboveGameBox.y+2
- end
- end
- if playerCount <= 3 then
- turnOrderBag.takeObject({
- position = aboveGameBox,
- guid = turnOrderFourCardGUID,
- })
- aboveGameBox.y = aboveGameBox.y+2
- for _, entries in ipairs(primaryObjective4PCardGUIDsTable) do
- primaryObjectivesDeck.takeObject({
- position = aboveGameBox,
- guid = entries,
- })
- aboveGameBox.y = aboveGameBox.y+2
- end
- gameBoxObj.putObject(getObjectFromGUID(escapePodThreeGUID))
- end
- if playerCount <= 2 then
- turnOrderBag.takeObject({
- position = aboveGameBox,
- guid = turnOrderThreeCardGUID,
- })
- aboveGameBox.y = aboveGameBox.y+2
- for _, entries in ipairs(primaryObjective3PCardGUIDsTable) do
- primaryObjectivesDeck.takeObject({
- position = aboveGameBox,
- guid = entries,
- })
- aboveGameBox.y = aboveGameBox.y+2
- end
- end
- if playerCount == 1 then
- turnOrderBag.takeObject({
- position = aboveGameBox,
- guid = turnOrderTwoCardGUID,
- })
- aboveGameBox.y = aboveGameBox.y+2
- for _, entries in ipairs(primaryObjective2PCardGUIDsTable) do
- primaryObjectivesDeck.takeObject({
- position = aboveGameBox,
- guid = entries,
- })
- aboveGameBox.y = aboveGameBox.y+2
- end
- gameBoxObj.putObject(getObjectFromGUID(escapePodFourGUID))
- end
- end
- function skipSetup()
- gameBoardObj.clearButtons()
- end
- function finalSetupStep()
- gameBoardObj.clearButtons()
- note = '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'
- note = note .. 'Any rule question? \n\n'
- note = note .. '- Check FAQ: https://goo.gl/ybd5qE \n\n'
- note = note .. '- Answer not found, ask here: https://goo.gl/DJf4cV \n\n'
- setNotes(note)
- gameBoxObj.putObject(levelOneRoomObj)
- gameBoxObj.putObject(levelTwoRoomObj)
- gameBoxObj.putObject(coordinateDeck)
- gameBoxObj.putObject(primaryObjectivesDeck)
- gameBoxObj.putObject(turnOrderBag)
- for _, playMat in ipairs(playerMatTable) do
- if playMat.getButtons() ~= nil then
- gameBoxObj.putObject(playMat)
- end
- end
- for _, zoneGUID in ipairs(playerMatZoneGUIDTable) do
- zoneObj = getObjectFromGUID(zoneGUID)
- if zoneObj ~= nil then
- zoneObj.destruct()
- end
- end
- --This will put unused crew memebers in the box
- for _, entries in ipairs(findCrewsEquipTable) do
- onTheTable = getObjectFromGUID(entries.matGUID)
- if onTheTable ~= nil and onTheTable.getDescription() ~= 'Keep' then
- crewEquipTable = entries.equipTable
- for _, equipEntries in ipairs(crewEquipTable) do
- gameBoxObj.putObject(getObjectFromGUID(equipEntries.objGUID))
- end
- figureToPlaceGUID = entries.figureGUID
- gameBoxObj.putObject(getObjectFromGUID(figureToPlaceGUID))
- gameBoxObj.putObject(onTheTable)
- end
- end
- end
- function shuffleCheck()
- currentCountInBag = intrudersBagObj.getObjects()
- if getObjectFromGUID(contaminationDeck.guid) ~= nil then
- currentCountInDeck = contaminationDeck.getObjects()
- end
- --sets the initial count for these variables
- if contaminationCount == nil or intruderPoolCount == nil then
- contaminationCount = 25
- intruderPoolCount = 8
- end
- if #currentCountInBag > intruderPoolCount then
- intrudersBagObj.shuffle()
- intruderPoolCount = #currentCountInBag
- else
- intruderPoolCount = #currentCountInBag
- end
- if #contaminationDeckZone.getObjects() ~= 0 then
- if getObjectFromGUID(contaminationDeck.guid) ~= nil then
- if #currentCountInDeck > contaminationCount then
- contaminationDeck.shuffle()
- contaminationCount = #currentCountInDeck
- else
- contaminationCount = #currentCountInDeck
- end
- else
- objInContamDeckZone = contaminationDeckZone.getObjects()
- if objInContamDeckZone[1].tag == 'Deck' then
- contaminationDeck = objInContamDeckZone[1]
- contaminationDeck.shuffle()
- end
- end
- else
- contaminationCount = 0
- end
- end
- --Builds a table for the locatoins to place game pieces.
- function buildPositionsTable()
- gamePiecePosTable = {
- --Level One Rooms
- {objToPullFrom = levelOneRoomObj, pos_object = {-13.69, 2, 0.45}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {-12.43, 2, 9.50}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {-4.30, 2, 12.47}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {2.83, 2, 10.85}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {10.65, 2, 10.08}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {13.68, 2, 4.66}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {13.71, 2, -3.75}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {10.56, 2, -9.09}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {2.77, 2, -9.89}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {-4.43, 2, -11.43}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelOneRoomObj, pos_object = {-12.47, 2, -8.23}, rot_object = {0.0, 180, 0.0}},
- --Level Two Rooms
- {objToPullFrom = levelTwoRoomObj, pos_object = {-7.88, 2, 0.33}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelTwoRoomObj, pos_object = {-3.48, 2, 6.01}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelTwoRoomObj, pos_object = {7.34, 2, 4.26}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelTwoRoomObj, pos_object = {7.32, 2, -3.21}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = levelTwoRoomObj, pos_object = {-3.41, 2, -5.16}, rot_object = {0.0, 180, 0.0}},
- --Explore Tokens
- {objToPullFrom = exploreTokenBagObj, pos_object = {-13.69, 2.5, 0.45}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {-12.43, 2.5, 9.50}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {-4.30, 2.5, 12.47}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {2.83, 2.5, 10.85}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {10.65, 2.5, 10.08}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {13.68, 2.5, 4.66}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {13.71, 2.5, -3.75}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {10.56, 2.5, -9.09}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {2.77, 2.5, -9.89}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {-4.43, 2.5, -11.43}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {-12.47, 2.5, -8.23}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {-7.88, 2.5, 0.33}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {-3.48, 2.5, 6.01}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {7.34, 2.5, 4.26}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {7.32, 2.5, -3.21}, rot_object = {0.0, 180, 0.0}},
- {objToPullFrom = exploreTokenBagObj, pos_object = {-3.41, 2.5, -5.16}, rot_object = {0.0, 180, 0.0}},
- --Intruder Weakness Deck
- {objToPullFrom = intruderWeakDeck, pos_object = {13.80, 1.64, 17.42}, rot_object = {0.0, 180, 180}},
- {objToPullFrom = intruderWeakDeck, pos_object = {17.00, 1.64, 17.41}, rot_object = {0.0, 180, 180}},
- {objToPullFrom = intruderWeakDeck, pos_object = {20.17, 1.63, 17.42}, rot_object = {0.0, 180, 180}},
- --Coordiantes Deck
- {objToPullFrom = coordinateDeck, pos_object = {-21.65, 5, 6.36} , rot_object = {0, 90, 180} },
- }
- end
- function buildCrewsEquipmentTable()
- captainEquipList = {
- {objGUID = captainDeckGUID , pos = {-4.15,3,0.65}},
- {objGUID = captainEquip01GUID , pos = {9.0,3,1.3}},
- {objGUID = captainEquip02GUID , pos = {9.0,3,-3.2}},
- }
- captainCubeTable = {
- {9.5,4,3},
- {8.8,4,3},
- }
- pilotEquipList = {
- {objGUID = pilotDeckGUID , pos = {-4.15,3,0.65}},
- {objGUID = pilotEquip01GUID , pos = {9.0,3,1.3}},
- {objGUID = pilotEquip02GUID , pos = {9.0,3,-3.2}},
- }
- pilotCubeTable = {
- {9.5,4,3},
- {8.8,4,3},
- }
- scientistEquipList = {
- {objGUID = scientistDeckGUID , pos = {-4.15,3,0.65}},
- {objGUID = scientistEquip01GUID , pos = {9.0,3,1.3}},
- {objGUID = scientistEquip02GUID , pos = {9.0,3,-3.2}},
- }
- scientistCubeTable = {
- {9.6,4,3},
- {9,4,3},
- {8.4,4,3},
- }
- scoutEquipList = {
- {objGUID = scoutDeckGUID , pos = {-4.15,3,0.65}},
- {objGUID = scoutEquip01GUID , pos = {9.0,3,1.3}},
- {objGUID = scoutEquip02GUID , pos = {9.0,3,-3.2}},
- }
- scoutCubeTable = {
- {10.0,4,3},
- {9.5,4,3},
- {9,4,3},
- {8.5,4,3},
- {8.0,4,3},
- {9.5,4,-1.5},
- {8.8,4,-1.5},
- }
- soldierEquipList = {
- {objGUID = soldierDeckGUID , pos = {-4.15,3,0.65}},
- {objGUID = soldierEquip01GUID , pos = {9.0,3,1.3}},
- {objGUID = soldierEquip02GUID , pos = {9.0,3,-3.2}},
- }
- soldierCubeTable = {
- {10.0,4,3},
- {9.5,4,3},
- {9,4,3},
- {8.5,4,3},
- {8.0,4,3},
- }
- mechanicEquipList = {
- {objGUID = mechanicDeckGUID , pos = {-4.15,3,0.65}},
- {objGUID = mechanicEquip01GUID , pos = {9.0,3,1.3}},
- {objGUID = mechanicEquip02GUID , pos = {9.0,3,-3.2}},
- }
- mechanicCubeTable = {
- {9.5,4,3},
- {8.8,4,3},
- }
- medicEquipList = {
- {objGUID = medicDeckGUID , pos = {-4.15,3,0.65}},
- {objGUID = medicEquip01GUID , pos = {9.0,3,1.3}},
- {objGUID = medicEquip02GUID , pos = {9.0,3,-3.2}},
- }
- medicCubeTable = {
- {10.0,4,3},
- {9.5,4,3},
- {9,4,3},
- {8.5,4,3},
- {8.0,4,3},
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement