Advertisement
Guest User

player() func

a guest
Dec 2nd, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1.  
  2. local function player(num)
  3.   while true do
  4.     if turn == num then
  5.       local d1 = math.random(1, 6)
  6.       local d2 = math.random(1, 6)
  7.       local moveCount = d1 + d2
  8.       print("Player "..num.." rolled a "..d1.." and a "..d2.."...")
  9.       if d1 == d2 then
  10.         print("Doubles! Rolling again.")
  11.         local d1 = math.random(1, 6)
  12.         local d2 = math.random(1, 6)
  13.         local moveCount = moveCount + d1 + d2
  14.         if d1 == d2 then
  15.           print("Doubles! Rolling again for a second time.")
  16.           local d1 = math.random(1, 6)
  17.           local d2 = math.random(1, 6)
  18.           local moveCount = moveCount + d1 + d2
  19.         end
  20.       end
  21.       if num == 1 then
  22.         spaceP1 = spaceP1 + moveCount
  23.         if board[spaceP1].owner == 0 then
  24.           if (type == 1 or type == 2 or type == 7) and (bank >= price + 200) then
  25.             local isBuying = math.random(1, 4)
  26.             if isBuying == 1 then
  27.               isBuying = true
  28.             end
  29.             if isBuying == true then
  30.               players[1].properties[#players[1].properties+1] = board[spaceP1].spaceNum
  31.               players[1].bank = players[1].bank - board[spaceP1].price
  32.               board[spaceP1].owner = 1
  33.             end
  34.           end
  35.         end
  36.       elseif num == 2 then
  37.         spaceP2 = spaceP2 + moveCount
  38.       elseif num == 3 then
  39.         spaceP3 = spaceP3 + moveCount
  40.       elseif num == 4 then
  41.         spaceP4 = spaceP4 + moveCount
  42.       elseif num == 5 then
  43.         spaceP5 = spaceP5 + moveCount
  44.       elseif num == 6 then
  45.         spaceP6 = spaceP6 + moveCount
  46.       end
  47.     end
  48.     if turn < 6 then
  49.       turn = turn + 1
  50.     elseif turn == 6 then
  51.       turn = 1
  52.     end
  53.   end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement