Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bingoboards()
- B = {
- math.ceil(math.random(1,20)),
- math.ceil(math.random(1,20)),
- math.ceil(math.random(1,20)),
- math.ceil(math.random(1,20)),
- math.ceil(math.random(1,20))
- }
- I = {
- math.ceil(math.random(21,40)),
- math.ceil(math.random(21,40)),
- math.ceil(math.random(21,40)),
- math.ceil(math.random(21,40)),
- math.ceil(math.random(21,40))
- }
- N = {
- math.ceil(math.random(41,60)),
- math.ceil(math.random(41,60)),
- " F ",
- math.ceil(math.random(41,60)),
- math.ceil(math.random(41,60))
- }
- G = {
- math.ceil(math.random(61,80)),
- math.ceil(math.random(61,80)),
- math.ceil(math.random(61,80)),
- math.ceil(math.random(61,80)),
- math.ceil(math.random(61,80))
- }
- O = {
- math.ceil(math.random(81,100)),
- math.ceil(math.random(81,100)),
- math.ceil(math.random(81,100)),
- math.ceil(math.random(81,100)),
- math.ceil(math.random(81,100))
- }
- for check=1,20 do
- for c=1,5 do
- for d=1,5 do
- if c ~= d then
- while B[c] == B[d] do
- B[c] = B[c] + 1
- if B[c] > 20 then
- B[c] = B[c] - 20
- end
- end
- while I[c] == I[d] do
- I[c] = I[c] + 1
- if I[c] > 40 then
- I[c] = I[c] - 20
- end
- end
- while N[c] == N[d] do
- N[c] = N[c] + 1
- if N[c] > 60 then
- N[c] = N[c] - 20
- end
- end
- while G[c] == G[d] do
- G[c] = G[c] + 1
- if G[c] > 80 then
- G[c] = G[c] - 20
- end
- end
- while O[c] == O[d] do
- O[c] = O[c] + 1
- if O[c] > 100 then
- O[c] = O[c] - 20
- end
- end
- end
- end
- end
- end
- for e=1,5 do
- B[e] = " "..tostring(B[e])
- B[e] = string.sub(B[e], string.len(B[e])-2, string.len(B[e]))
- I[e] = " "..tostring(I[e])
- I[e] = string.sub(I[e], string.len(I[e])-2, string.len(I[e]))
- N[e] = " "..tostring(N[e])
- N[e] = string.sub(N[e], string.len(N[e])-2, string.len(N[e]))
- G[e] = " "..tostring(G[e])
- G[e] = string.sub(G[e], string.len(G[e])-2, string.len(G[e]))
- O[e] = " "..tostring(O[e])
- O[e] = string.sub(O[e], string.len(O[e])-2, string.len(O[e]))
- end
- end
- callednums = {}
- function callnums()
- callnum = math.ceil(math.random(1,100))
- for check=1,100 do
- for n=1,100 do
- while callnum == callednums[n] do
- callnum = callnum + 1
- if callnum > 100 then
- callnum = callnum - 100
- end
- end
- end
- end
- table.insert(callednums,1,callnum)
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- print("Called Number: "..callnum.." ")
- end
- function setboards()
- term.clear()
- term.setCursorPos(1,1)
- print("")
- print("")
- print("Player 1 Player 2 ")
- print("--------------------- ---------------------")
- print("| B | I | N | G | O | | B | I | N | G | O |")
- print("|---|---|---|---|---| |---|---|---|---|---|")
- print("|"..B1[1].."|"..I1[1].."|"..N1[1].."|"..G1[1].."|"..O1[1].."| |"..B2[1].."|"..I2[1].."|"..N2[1].."|"..G2[1].."|"..O2[1].."|")
- print("|---|---|---|---|---| |---|---|---|---|---|")
- print("|"..B1[2].."|"..I1[2].."|"..N1[2].."|"..G1[2].."|"..O1[2].."| |"..B2[2].."|"..I2[2].."|"..N2[2].."|"..G2[2].."|"..O2[2].."|")
- print("|---|---|---|---|---| |---|---|---|---|---|")
- print("|"..B1[3].."|"..I1[3].."|"..N1[3].."|"..G1[3].."|"..O1[3].."| |"..B2[3].."|"..I2[3].."|"..N2[3].."|"..G2[3].."|"..O2[3].."|")
- print("|---|---|---|---|---| |---|---|---|---|---|")
- print("|"..B1[4].."|"..I1[4].."|"..N1[4].."|"..G1[4].."|"..O1[4].."| |"..B2[4].."|"..I2[4].."|"..N2[4].."|"..G2[4].."|"..O2[4].."|")
- print("|---|---|---|---|---| |---|---|---|---|---|")
- print("|"..B1[5].."|"..I1[5].."|"..N1[5].."|"..G1[5].."|"..O1[5].."| |"..B2[5].."|"..I2[5].."|"..N2[5].."|"..G2[5].."|"..O2[5].."|")
- print("--------------------- ---------------------")
- print(" Pass Pass ")
- end
- function p1input()
- if xPos >= 2 and xPos <= 4 then
- if yPos == 7 and tonumber(B1[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(2,7)
- B1[1] = " X "
- write(B1[1])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 9 and tonumber(B1[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(2,9)
- B1[2] = " X "
- write(B1[2])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 11 and tonumber(B1[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(2,11)
- B1[3] = " X "
- write(B1[3])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 13 and tonumber(B1[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(2,13)
- B1[4] = " X "
- write(B1[4])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 15 and tonumber(B1[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(2,15)
- B1[5] = " X "
- write(B1[5])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- end
- elseif xPos >= 6 and xPos <= 8 then
- if yPos == 7 and tonumber(I1[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(6,7)
- I1[1] = " X "
- write(I1[1])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 9 and tonumber(I1[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(6,9)
- I1[2] = " X "
- write(I1[2])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 11 and tonumber(I1[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(6,11)
- I1[3] = " X "
- write(I1[3])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 13 and tonumber(I1[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(6,13)
- I1[4] = " X "
- write(I1[4])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 15 and tonumber(I1[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(6,15)
- I1[5] = " X "
- write(I1[5])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- end
- elseif xPos >= 10 and xPos <= 12 then
- if yPos == 7 and tonumber(N1[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(10,7)
- N1[1] = " X "
- write(N1[1])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 9 and tonumber(N1[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(10,9)
- N1[2] = " X "
- write(N1[2])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 11 and N1[3] == " F " then
- term.setTextColor(colors.red)
- term.setCursorPos(10,11)
- N1[3] = " X "
- write(N1[3])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 13 and tonumber(N1[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(10,13)
- N1[4] = " X "
- write(N1[4])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 15 and tonumber(N1[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(10,15)
- N1[5] = " X "
- write(N1[5])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- end
- elseif xPos >= 14 and xPos <= 16 then
- if yPos == 7 and tonumber(G1[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(14,7)
- G1[1] = " X "
- write(G1[1])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 9 and tonumber(G1[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(14,9)
- G1[2] = " X "
- write(G1[2])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 11 and tonumber(G1[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(14,11)
- G1[3] = " X "
- write(G1[3])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 13 and tonumber(G1[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(14,13)
- G1[4] = " X "
- write(G1[4])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 15 and tonumber(G1[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(14,15)
- G1[5] = " X "
- write(G1[5])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- end
- elseif xPos >= 18 and xPos <= 20 then
- if yPos == 7 and tonumber(O1[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(18,7)
- O1[1] = " X "
- write(O1[1])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 9 and tonumber(O1[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(18,9)
- O1[2] = " X "
- write(O1[2])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 11 and tonumber(O1[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(18,11)
- O1[3] = " X "
- write(O1[3])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 13 and tonumber(O1[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(18,13)
- O1[4] = " X "
- write(O1[4])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- elseif yPos == 15 and tonumber(O1[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(18,15)
- O1[5] = " X "
- write(O1[5])
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- end
- end
- if xPos >= 9 and xPos <= 12 and yPos == 17 then
- p1turn = false
- term.setCursorPos(1,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 2...")
- end
- end
- function aiinput()
- sleep(2)
- if tonumber(B2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,7)
- B2[1] = " X "
- write(B2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(B2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,9)
- B2[2] = " X "
- write(B2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(B2[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,11)
- B2[3] = " X "
- write(B2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(B2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,13)
- B2[4] = " X "
- write(B2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(B2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,15)
- B2[5] = " X "
- write(B2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(I2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,7)
- I2[1] = " X "
- write(I2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(I2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,9)
- I2[2] = " X "
- write(I2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(I2[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,11)
- I2[3] = " X "
- write(I2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(I2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,13)
- I2[4] = " X "
- write(I2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(I2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,15)
- I2[5] = " X "
- write(I2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(N2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(34,7)
- N2[1] = " X "
- write(N2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(N2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(34,9)
- N2[2] = " X "
- write(N2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(N2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(34,13)
- N2[4] = " X "
- write(N2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(N2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(34,15)
- N2[5] = " X "
- write(N2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(G2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,7)
- G2[1] = " X "
- write(G2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(G2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,9)
- G2[2] = " X "
- write(G2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(G2[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,11)
- G2[3] = " X "
- write(G2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(G2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,13)
- G2[4] = " X "
- write(G2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(G2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,15)
- G2[5] = " X "
- write(G2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(O2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,7)
- O2[1] = " X "
- write(O2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(O2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,9)
- O2[2] = " X "
- write(O2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(O2[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,11)
- O2[3] = " X "
- write(O2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(O2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,13)
- O2[4] = " X "
- write(O2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif tonumber(O2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,15)
- O2[5] = " X "
- write(O2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif N2[3] == " F " then
- term.setTextColor(colors.red)
- term.setCursorPos(34,11)
- N2[3] = " X "
- write(N2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- else
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- end
- end
- function p2input()
- if xPos >= 26 and xPos <= 28 then
- if yPos == 7 and tonumber(B2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,7)
- B2[1] = " X "
- write(B2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 9 and tonumber(B2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,9)
- B2[2] = " X "
- write(B2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 11 and tonumber(B2[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,11)
- B2[3] = " X "
- write(B2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 13 and tonumber(B2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,13)
- B2[4] = " X "
- write(B2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 15 and tonumber(B2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(26,15)
- B2[5] = " X "
- write(B2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- end
- elseif xPos >= 30 and xPos <= 32 then
- if yPos == 7 and tonumber(I2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,7)
- I2[1] = " X "
- write(I2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 9 and tonumber(I2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,9)
- I2[2] = " X "
- write(I2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 11 and tonumber(I2[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,11)
- I2[3] = " X "
- write(I2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 13 and tonumber(I2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,13)
- I2[4] = " X "
- write(I2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 15 and tonumber(I2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(30,15)
- I2[5] = " X "
- write(I2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- end
- elseif xPos >= 34 and xPos <= 36 then
- if yPos == 7 and tonumber(N2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(34,7)
- N2[1] = " X "
- write(N2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 9 and tonumber(N2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(34,9)
- N2[2] = " X "
- write(N2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 11 and N2[3] == " F " then
- term.setTextColor(colors.red)
- term.setCursorPos(34,11)
- N2[3] = " X "
- write(N2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 13 and tonumber(N2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(34,13)
- N2[4] = " X "
- write(N2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 15 and tonumber(N2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(34,15)
- N2[5] = " X "
- write(N2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- end
- elseif xPos >= 38 and xPos <= 40 then
- if yPos == 7 and tonumber(G2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,7)
- G2[1] = " X "
- write(G2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 9 and tonumber(G2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,9)
- G2[2] = " X "
- write(G2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 11 and tonumber(G2[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,11)
- G2[3] = " X "
- write(G2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 13 and tonumber(G2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,13)
- G2[4] = " X "
- write(G2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 15 and tonumber(G2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(38,15)
- G2[5] = " X "
- write(G2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- end
- elseif xPos >= 42 and xPos <= 44 then
- if yPos == 7 and tonumber(O2[1]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,7)
- O2[1] = " X "
- write(O2[1])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 9 and tonumber(O2[2]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,9)
- O2[2] = " X "
- write(O2[2])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 11 and tonumber(O2[3]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,11)
- O2[3] = " X "
- write(O2[3])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 13 and tonumber(O2[4]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,13)
- O2[4] = " X "
- write(O2[4])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- elseif yPos == 15 and tonumber(O2[5]) == callnum then
- term.setTextColor(colors.red)
- term.setCursorPos(42,15)
- O2[5] = " X "
- write(O2[5])
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- end
- end
- if xPos >= 33 and xPos <= 36 and yPos == 17 then
- p2turn = false
- term.setCursorPos(25,18)
- term.setTextColor(colors.white)
- write("Waiting for Player 1...")
- end
- end
- function inputs()
- p1turn = true
- p2turn = true
- while true do
- if p2game == true then
- event, button, xPos, yPos = os.pullEvent()
- if p1turn == true and xPos <= 21 then
- if event == "mouse_click" and button == 1 then
- p1input()
- end
- end
- if p2turn == true and xPos >= 25 then
- if event == "mouse_click" and button == 1 then
- p2input()
- end
- end
- else
- if p1turn == true then
- event, button, xPos, yPos = os.pullEvent()
- if event == "mouse_click" and button == 1 then
- p1input()
- end
- else
- aiinput()
- end
- end
- if p1turn == false and p2turn == false then
- break
- end
- end
- term.setCursorPos(1,18)
- write(" ")
- end
- function wincheck()
- if (B1[1] == " X " and B1[2] == " X " and B1[3] == " X " and B1[4] == " X " and B1[5] == " X ")
- or (I1[1] == " X " and I1[2] == " X " and I1[3] == " X " and I1[4] == " X " and I1[5] == " X ")
- or (N1[1] == " X " and N1[2] == " X " and N1[3] == " X " and N1[4] == " X " and N1[5] == " X ")
- or (G1[1] == " X " and G1[2] == " X " and G1[3] == " X " and G1[4] == " X " and G1[5] == " X ")
- or (O1[1] == " X " and O1[2] == " X " and O1[3] == " X " and O1[4] == " X " and O1[5] == " X ")
- or (B1[1] == " X " and I1[1] == " X " and N1[1] == " X " and G1[1] == " X " and O1[1] == " X ")
- or (B1[2] == " X " and I1[2] == " X " and N1[2] == " X " and G1[2] == " X " and O1[2] == " X ")
- or (B1[3] == " X " and I1[3] == " X " and N1[3] == " X " and G1[3] == " X " and O1[3] == " X ")
- or (B1[4] == " X " and I1[4] == " X " and N1[4] == " X " and G1[4] == " X " and O1[4] == " X ")
- or (B1[5] == " X " and I1[5] == " X " and N1[5] == " X " and G1[5] == " X " and O1[5] == " X ")
- or (B1[1] == " X " and I1[2] == " X " and N1[3] == " X " and G1[4] == " X " and O1[5] == " X ")
- or (B1[5] == " X " and I1[4] == " X " and N1[3] == " X " and G1[2] == " X " and O1[1] == " X ") then
- winner = 1
- end
- if (B2[1] == " X " and B2[2] == " X " and B2[3] == " X " and B2[4] == " X " and B2[5] == " X ")
- or (I2[1] == " X " and I2[2] == " X " and I2[3] == " X " and I2[4] == " X " and I2[5] == " X ")
- or (N2[1] == " X " and N2[2] == " X " and N2[3] == " X " and N2[4] == " X " and N2[5] == " X ")
- or (G2[1] == " X " and G2[2] == " X " and G2[3] == " X " and G2[4] == " X " and G2[5] == " X ")
- or (O2[1] == " X " and O2[2] == " X " and O2[3] == " X " and O2[4] == " X " and O2[5] == " X ")
- or (B2[1] == " X " and I2[1] == " X " and N2[1] == " X " and G2[1] == " X " and O2[1] == " X ")
- or (B2[2] == " X " and I2[2] == " X " and N2[2] == " X " and G2[2] == " X " and O2[2] == " X ")
- or (B2[3] == " X " and I2[3] == " X " and N2[3] == " X " and G2[3] == " X " and O2[3] == " X ")
- or (B2[4] == " X " and I2[4] == " X " and N2[4] == " X " and G2[4] == " X " and O2[4] == " X ")
- or (B2[5] == " X " and I2[5] == " X " and N2[5] == " X " and G2[5] == " X " and O2[5] == " X ")
- or (B2[1] == " X " and I2[2] == " X " and N2[3] == " X " and G2[4] == " X " and O2[5] == " X ")
- or (B2[5] == " X " and I2[4] == " X " and N2[3] == " X " and G2[2] == " X " and O2[1] == " X ") then
- if winner == 1 then
- winner = 3
- else
- winner = 2
- end
- end
- end
- wins = 0
- losses = 0
- draws1 = 0
- player1 = 0
- player2 = 0
- draws2 = 0
- if fs.exists("bingo/stats") then
- stats = fs.open("bingo/stats","r")
- wins = stats.readLine()
- losses = stats.readLine()
- draws1 = stats.readLine()
- player1 = stats.readLine()
- player2 = stats.readLine()
- draws2 = stats.readLine()
- stats.close()
- end
- p1game = true
- p2game = false
- term.clear()
- term.setCursorPos(1,1)
- print("BingoCraft by theTANCO.")
- print("")
- print("[ 1 Player Game ]")
- print(" 2 Player Game ")
- print("")
- print("Select an Option and press Enter to begin.")
- while true do
- event, key = os.pullEvent("key")
- if key == 208 then
- term.setCursorPos(1,3)
- print(" 1 Player Game ")
- print("[ 2 Player Game ]")
- p1game = false
- p2game = true
- elseif key == 200 then
- term.setCursorPos(1,3)
- print("[ 1 Player Game ]")
- print(" 2 Player Game ")
- p1game = true
- p2game = false
- elseif key == 28 or key == 156 then
- term.setCursorPos(1,8)
- print("")
- print("Loading...")
- break
- end
- end
- bingoboards()
- B1 = B
- I1 = I
- N1 = N
- G1 = G
- O1 = O
- bingoboards()
- B2 = B
- I2 = I
- N2 = N
- G2 = G
- O2 = O
- winner = 0
- term.clear()
- setboards()
- for g=1,100 do
- callnums()
- inputs()
- wincheck()
- if winner > 0 then
- break
- end
- end
- stats = fs.open("bingo/stats","w")
- if winner == 0 then
- winner = 3
- end
- if p2game == true then
- if winner == 1 then
- player1 = player1 + 1
- end
- if winner == 2 then
- player2 = player2 + 1
- end
- if winner == 3 then
- draws2 = draws2 + 1
- end
- else
- if winner == 1 then
- wins = wins + 1
- end
- if winner == 2 then
- losses = losses + 1
- end
- if winner == 3 then
- draws1 = draws1 + 1
- end
- end
- stats.writeLine(wins)
- stats.writeLine(losses)
- stats.writeLine(draws1)
- stats.writeLine(player1)
- stats.writeLine(player2)
- stats.writeLine(draws2)
- stats.close()
- term.setTextColor(colors.white)
- term.setCursorPos(1,18)
- if winner == 3 then
- print("Game over! It's a draw! ")
- elseif winner > 0 and winner < 3 then
- print("Game over! Player "..winner.." wins! ")
- end
- print("Press Enter to end game or Space to start new game.")
- write("Press S to see stats or R to reset stats.")
- viewingstats = true
- resetting = true
- while true do
- event, button = os.pullEvent("key")
- if button == 28 or button == 156 or button == 57 then
- break
- elseif button == 31 and viewingstats == true then
- term.clear()
- term.setCursorPos(1,1)
- print("Win/Loss Statistics")
- print("")
- print("1 Player Games")
- print("Wins: "..math.floor(wins))
- print("Losses: "..math.floor(losses))
- print("Draws: "..math.floor(draws1))
- p1games = wins + losses + draws1
- print("Games Played: "..math.floor(p1games))
- print("")
- print("2 Player Games")
- print("Player 1: "..math.floor(player1))
- print("Player 2: "..math.floor(player2))
- print("Draws: "..math.floor(draws2))
- p2games = player1 + player2 + draws2
- print("Games Played: "..math.floor(p2games))
- print("")
- print("Press Enter to end game or Space to start new game.")
- write("Press R to reset stats.")
- viewingstats = false
- elseif button == 19 and resetting == true then
- fs.delete("bingo/stats")
- wins = 0
- losses = 0
- draws1 = 0
- player1 = 0
- player2 = 0
- draws2 = 0
- if viewingstats == false then
- term.clear()
- term.setCursorPos(1,1)
- print("Win/Loss Statistics")
- print("")
- print("1 Player Games")
- print("Wins: "..tostring(wins))
- print("Losses: "..tostring(losses))
- print("Draws: "..tostring(draws1))
- p1games = wins + losses + draws1
- print("Games Played: "..tostring(p1games))
- print("")
- print("2 Player Games")
- print("Player 1: "..tostring(player1))
- print("Player 2: "..tostring(player2))
- print("Draws: "..tostring(draws2))
- p2games = player1 + player2 + draws2
- print("Games Played: "..tostring(p2games))
- print("")
- print("Press Enter to end game or Space to start new game.")
- write("Press R to reset stats.")
- end
- write("\nStats reset.")
- resetting = false
- end
- end
- if button == 57 then
- shell.run("restartgame")
- elseif button == 28 or button == 156 then
- shell.run("clear")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement