Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Global Variables --]]
- --Setting up the start button
- print('starting')
- start_button = {}
- start_button_guid = '9df5e8'
- --Setting up all the boards of different sizes
- five_board = {}
- five_board_guid = 'f6027b'
- six_board = {}
- six_board_guid = '74cc28'
- seven_board = {}
- seven_board_guid = '4a8b42'
- --I don't have the ninth and tenth boards but the eight is mostly the same
- eight_board = {}
- eight_board_guid = '5fb4ae'
- --Setting up the decks and role cards
- --Decks
- arthur_deck = {}
- arthur_deck_guid = '18f8a7'
- mordred_deck = {}
- mordred_deck_guid = '1b644e'
- --Role cards
- merlin_card = {}
- merlin_card_guid = 'edf463'
- assassin_card = {}
- assassin_card_guid = 'b87f2f'
- percival_card = {}
- percival_card_guid = '64e82b'
- morgana_card = {}
- morgana_card_guid = '5fe648'
- oberon_card = {}
- oberon_card_guid = '72d3dc'
- mordred_card = {}
- mordred_card_guid = '1f357e'
- arthur_max = 0
- mordred_max = 0
- --Setting up the yes and no vote cards
- yes_deck = {}
- yes_deck_guid = 'd258bd'
- no_deck = {}
- no_deck_guid = '8b3daf'
- --Setting up hidden zones
- select_zone = {}
- select_zone_guid = '765404'
- trash_zone = {}
- trash_zone_guid = '49803a'
- move_zone= {}
- move_zone_guid = '388ffd'
- num_players = 0
- timNum = 0
- roles = {}
- print('global variables set')
- --[[ The OnLoad function. Called when a game finishes loading. --]]
- function onload()
- print('onload function started')
- --Setting up the button that deals the roles out when pressed
- start_button = getObjectFromGUID(start_button_guid)
- local button = {}
- button.click_function = "startGame"
- button.label = 'Start'
- button.function_owner = nil
- --Not sure where this is going yet, let's put it in and see
- button.position = {0, 0, 0}
- button.rotation = {0,0,0}
- button.width = 1600
- button.height = 1000
- button.font_size = 500
- --Creates a button object called button with the properties above
- start_button.createButton(button)
- print('button created')
- --Setting up the boards and cards, linking them with the guids
- five_board = getObjectFromGUID(five_board_guid)
- six_board = getObjectFromGUID(six_board_guid)
- seven_board = getObjectFromGUID(seven_board_guid)
- eight_board = getObjectFromGUID(eight_board_guid)
- --Setting up the decks and cards now
- arthur_deck = getObjectFromGUID(arthur_deck_guid)
- mordred_deck = getObjectFromGUID(mordred_deck_guid)
- merlin_card = getObjectFromGUID(merlin_card_guid)
- assassin_card = getObjectFromGUID(assassin_card_guid)
- percival_card = getObjectFromGUID(percival_card_guid)
- morgana_card = getObjectFromGUID(morgana_card_guid)
- oberon_card = getObjectFromGUID(oberon_card_guid)
- mordred_card = getObjectFromGUID(mordred_card_guid)
- --Setting up yes and no votes
- yes_deck = getObjectFromGUID(yes_deck_guid)
- no_deck = getObjectFromGUID(no_deck_guid)
- --Setting up hidden zones that select/delete cards
- --view these zones with the zone script option the right clicking
- --the guids will be put into chat
- select_zone = getObjectFromGUID(select_zone_guid)
- trash_zone = getObjectFromGUID(trash_zone_guid)
- move_zone = getObjectFromGUID(move_zone_guid)
- print('guids are guid to go')
- end
- function startGame()
- players = getSeatedPlayers()
- setup(#players)
- destroyObject(start_button)
- end
- --Setup Function
- function setup (np)
- if np > 4 and np < 11 then
- --We need to find out what/how many cards are in the select zone
- arthur_count = 0
- local inZone = select_zone.getObjects()
- for i, j in ipairs(inZone) do
- if(j.getDescription() == 'Arthur') then
- arthur_count = arthur_count + 1
- end
- end
- --figuring out the max arthur and mordred on each team
- if(np == 5) then
- arthur_max = 3
- mordred_max = 2
- --Setting up the board and destroying the ones we do not need
- five_board.setPosition({0, 1, 5})
- five_board.lock()
- destroyObject(six_board)
- destroyObject(seven_board)
- destroyObject(eight_board)
- elseif(np == 6) then
- arthur_max = 4
- mordred_max = 2
- six_board.setPosition({0, 1, 5})
- six_board.lock()
- destroyObject(five_board)
- destroyObject(seven_board)
- destroyObject(eight_board)
- elseif(np == 7) then
- arthur_max = 4
- mordred_max = 3
- seven_board.setPosition({0, 1, 5})
- seven_board.lock()
- destroyObject(five_board)
- destroyObject(six_board)
- destroyObject(eight_board)
- elseif(np == 8) then
- arthur_max = 5
- mordred_max = 3
- eight_board.setPosition({0, 1, 5})
- eight_board.lock()
- destroyObject(five_board)
- destroyObject(six_board)
- destroyObject(seven_board)
- elseif(np == 9) then
- arthur_max = 6
- mordred_max = 3
- eight_board.setPosition({0, 1, 5})
- eight_board.lock()
- destroyObject(five_board)
- destroyObject(six_board)
- destroyObject(seven_board)
- else
- arthur_max = 6
- mordred_max = 4
- eight_board.setPosition({0, 1, 5})
- eight_board.lock()
- destroyObject(five_board)
- destroyObject(six_board)
- destroyObject(seven_board)
- end
- --# returns the number of things in the list/array i don't know honestly
- print("There are " .. arthur_count .. " special servants of Arthur and " .. (#inZone - arthur_count) .. " minions of mordred.")
- if((#inZone - arthur_count) > arthur_max) then
- print('Too many minions of Mordred! Remove some.')
- elseif(arthur_count > mordred_max) then
- print('Too many servants of Arthur! Remove some.')
- else
- print('Legal number of Servants anad Minions!')
- --Setting the max number of servants and minions
- --Moving the cards in select zone to move zone
- --setting up parameters for the cards to move to
- local params = {}
- params.position = {-30, 1.5, -15}
- --Moving the normal cards into the move zone
- arthur_deck.shuffle()
- mordred_deck.shuffle()
- mordred_count = #inZone - arthur_count
- --This number depends on the max number of mordred
- while(mordred_count < mordred_max) do
- mordred_deck.takeObject(params)
- mordred_count = mordred_count + 1
- end
- --This number depends on the max number of arthur
- while(arthur_count < arthur_max) do
- arthur_deck.takeObject(params)
- arthur_count = arthur_count + 1
- end
- for i, j in ipairs(inZone) do
- j.flip()
- end
- number_of_cards_in_zone = #inZone
- print(number_of_cards_in_zone)
- --sleep(1, setup2())
- sleep(1, 'grabRoles')
- end
- else
- print('Not Enough Players!')
- end
- end
- --this fucntion will bring the cards together
- function grabRoles()
- print('grabbing roles!')
- local inZone = select_zone.getObjects()
- for i, j in ipairs(inZone) do
- j.setPosition({-30, 1.5, -15})
- end
- sleep(1, 'shuffleCards')
- return 1
- end
- function shuffleCards()
- local inZone = move_zone.getObjects()
- print('shuffling the deck!')
- inZone[1].shuffle()
- sleep(1, 'dealCards')
- return 1
- end
- function dealCards()
- local inZone = move_zone.getObjects()
- print('dealing the cards')
- for i, j in ipairs(players) do
- local tempCard = inZone[1].dealToColorWithOffset({0,0,0}, false, j)
- if tempCard == nil then
- print ('nil')
- end
- playerHand = getPlayerHandPositionAndRotation(j)
- roles[j] = tempCard.getName()
- print('trying to print the roles as they are dealt')
- print(roles[j])
- end
- for i, j in ipairs(players) do
- yes_deck.dealToAll(1)
- no_deck.dealToAll(1)
- end
- function sleep(n, to_do)
- Timer.destroy('t' .. timNum)
- timNum = timNum + 1
- timer = {}
- timer.identifier = 't' .. timNum
- timer.delay = n
- timer.function_name = to_do
- timer.repetitions = 1
- Timer.create(timer)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement