Advertisement
Guest User

game

a guest
Apr 20th, 2015
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 33.98 KB | None | 0 0
  1. function bingoboards()
  2.   B = {
  3.     math.ceil(math.random(1,20)),
  4.     math.ceil(math.random(1,20)),
  5.     math.ceil(math.random(1,20)),
  6.     math.ceil(math.random(1,20)),
  7.     math.ceil(math.random(1,20))
  8.   }
  9.   I = {
  10.     math.ceil(math.random(21,40)),
  11.     math.ceil(math.random(21,40)),
  12.     math.ceil(math.random(21,40)),
  13.     math.ceil(math.random(21,40)),
  14.     math.ceil(math.random(21,40))
  15.   }
  16.   N = {
  17.     math.ceil(math.random(41,60)),
  18.     math.ceil(math.random(41,60)),
  19.     " F ",
  20.     math.ceil(math.random(41,60)),
  21.     math.ceil(math.random(41,60))
  22.   }
  23.   G = {
  24.     math.ceil(math.random(61,80)),
  25.     math.ceil(math.random(61,80)),
  26.     math.ceil(math.random(61,80)),
  27.     math.ceil(math.random(61,80)),
  28.     math.ceil(math.random(61,80))
  29.   }
  30.   O = {
  31.     math.ceil(math.random(81,100)),
  32.     math.ceil(math.random(81,100)),
  33.     math.ceil(math.random(81,100)),
  34.     math.ceil(math.random(81,100)),
  35.     math.ceil(math.random(81,100))
  36.   }
  37.   for check=1,20 do
  38.     for c=1,5 do
  39.       for d=1,5 do
  40.         if c ~= d then
  41.           while B[c] == B[d] do
  42.             B[c] = B[c] + 1
  43.             if B[c] > 20 then
  44.               B[c] = B[c] - 20
  45.             end
  46.           end
  47.           while I[c] == I[d] do
  48.             I[c] = I[c] + 1
  49.             if I[c] > 40 then
  50.               I[c] = I[c] - 20
  51.             end
  52.           end
  53.           while N[c] == N[d] do
  54.             N[c] = N[c] + 1
  55.             if N[c] > 60 then
  56.               N[c] = N[c] - 20
  57.             end
  58.           end
  59.           while G[c] == G[d] do
  60.             G[c] = G[c] + 1
  61.              if G[c] > 80 then
  62.               G[c] = G[c] - 20
  63.             end
  64.           end
  65.           while O[c] == O[d] do
  66.             O[c] = O[c] + 1
  67.             if O[c] > 100 then
  68.               O[c] = O[c] - 20
  69.             end
  70.           end
  71.         end
  72.       end
  73.     end
  74.   end
  75.   for e=1,5 do
  76.     B[e] = "   "..tostring(B[e])
  77.     B[e] = string.sub(B[e], string.len(B[e])-2, string.len(B[e]))
  78.  
  79.     I[e] = "   "..tostring(I[e])
  80.     I[e] = string.sub(I[e], string.len(I[e])-2, string.len(I[e]))
  81.  
  82.     N[e] = "   "..tostring(N[e])
  83.     N[e] = string.sub(N[e], string.len(N[e])-2, string.len(N[e]))
  84.  
  85.     G[e] = "   "..tostring(G[e])
  86.     G[e] = string.sub(G[e], string.len(G[e])-2, string.len(G[e]))
  87.  
  88.     O[e] = "   "..tostring(O[e])
  89.     O[e] = string.sub(O[e], string.len(O[e])-2, string.len(O[e]))
  90.   end
  91. end
  92.  
  93. callednums = {}
  94. function callnums()
  95.   callnum = math.ceil(math.random(1,100))
  96.   for check=1,100 do
  97.     for n=1,100 do
  98.       while callnum == callednums[n] do
  99.         callnum = callnum + 1
  100.         if callnum > 100 then
  101.           callnum = callnum - 100
  102.         end
  103.       end
  104.     end
  105.   end
  106.   table.insert(callednums,1,callnum)
  107.   term.setCursorPos(1,1)
  108.   term.setTextColor(colors.white)
  109.   print("Called Number: "..callnum.."   ")
  110. end
  111.  
  112. function setboards()
  113.   term.clear()
  114.   term.setCursorPos(1,1)
  115.   print("")
  116.   print("")
  117.   print("Player 1                Player 2             ")
  118.   print("---------------------   ---------------------")
  119.   print("| B | I | N | G | O |   | B | I | N | G | O |")
  120.   print("|---|---|---|---|---|   |---|---|---|---|---|")
  121.   print("|"..B1[1].."|"..I1[1].."|"..N1[1].."|"..G1[1].."|"..O1[1].."|   |"..B2[1].."|"..I2[1].."|"..N2[1].."|"..G2[1].."|"..O2[1].."|")
  122.   print("|---|---|---|---|---|   |---|---|---|---|---|")
  123.   print("|"..B1[2].."|"..I1[2].."|"..N1[2].."|"..G1[2].."|"..O1[2].."|   |"..B2[2].."|"..I2[2].."|"..N2[2].."|"..G2[2].."|"..O2[2].."|")
  124.   print("|---|---|---|---|---|   |---|---|---|---|---|")
  125.   print("|"..B1[3].."|"..I1[3].."|"..N1[3].."|"..G1[3].."|"..O1[3].."|   |"..B2[3].."|"..I2[3].."|"..N2[3].."|"..G2[3].."|"..O2[3].."|")
  126.   print("|---|---|---|---|---|   |---|---|---|---|---|")
  127.   print("|"..B1[4].."|"..I1[4].."|"..N1[4].."|"..G1[4].."|"..O1[4].."|   |"..B2[4].."|"..I2[4].."|"..N2[4].."|"..G2[4].."|"..O2[4].."|")
  128.   print("|---|---|---|---|---|   |---|---|---|---|---|")
  129.   print("|"..B1[5].."|"..I1[5].."|"..N1[5].."|"..G1[5].."|"..O1[5].."|   |"..B2[5].."|"..I2[5].."|"..N2[5].."|"..G2[5].."|"..O2[5].."|")
  130.   print("---------------------   ---------------------")
  131.   print("        Pass                    Pass         ")
  132. end
  133.  
  134. function p1input()
  135.   if xPos >= 2 and xPos <= 4 then
  136.     if yPos == 7 and tonumber(B1[1]) == callnum then
  137.       term.setTextColor(colors.red)
  138.       term.setCursorPos(2,7)
  139.       B1[1] = " X "
  140.       write(B1[1])
  141.       p1turn = false
  142.       term.setCursorPos(1,18)
  143.       term.setTextColor(colors.white)
  144.       write("Waiting for Player 2...")
  145.     elseif yPos == 9 and tonumber(B1[2]) == callnum then
  146.       term.setTextColor(colors.red)
  147.       term.setCursorPos(2,9)
  148.       B1[2] = " X "
  149.       write(B1[2])
  150.       p1turn = false
  151.       term.setCursorPos(1,18)
  152.       term.setTextColor(colors.white)
  153.       write("Waiting for Player 2...")
  154.     elseif yPos == 11 and tonumber(B1[3]) == callnum then
  155.       term.setTextColor(colors.red)
  156.       term.setCursorPos(2,11)
  157.       B1[3] = " X "
  158.       write(B1[3])
  159.       p1turn = false
  160.       term.setCursorPos(1,18)
  161.       term.setTextColor(colors.white)
  162.       write("Waiting for Player 2...")
  163.     elseif yPos == 13 and tonumber(B1[4]) == callnum then
  164.       term.setTextColor(colors.red)
  165.       term.setCursorPos(2,13)
  166.       B1[4] = " X "
  167.       write(B1[4])
  168.       p1turn = false
  169.       term.setCursorPos(1,18)
  170.       term.setTextColor(colors.white)
  171.       write("Waiting for Player 2...")
  172.     elseif yPos == 15 and tonumber(B1[5]) == callnum then
  173.       term.setTextColor(colors.red)
  174.       term.setCursorPos(2,15)
  175.       B1[5] = " X "
  176.       write(B1[5])
  177.       p1turn = false
  178.       term.setCursorPos(1,18)
  179.       term.setTextColor(colors.white)
  180.       write("Waiting for Player 2...")
  181.     end
  182.   elseif xPos >= 6 and xPos <= 8 then
  183.     if yPos == 7 and tonumber(I1[1]) == callnum then
  184.       term.setTextColor(colors.red)
  185.       term.setCursorPos(6,7)
  186.       I1[1] = " X "
  187.       write(I1[1])
  188.       p1turn = false
  189.       term.setCursorPos(1,18)
  190.       term.setTextColor(colors.white)
  191.       write("Waiting for Player 2...")
  192.     elseif yPos == 9 and tonumber(I1[2]) == callnum then
  193.       term.setTextColor(colors.red)
  194.       term.setCursorPos(6,9)
  195.       I1[2] = " X "
  196.       write(I1[2])
  197.       p1turn = false
  198.       term.setCursorPos(1,18)
  199.       term.setTextColor(colors.white)
  200.       write("Waiting for Player 2...")
  201.     elseif yPos == 11 and tonumber(I1[3]) == callnum then
  202.       term.setTextColor(colors.red)
  203.       term.setCursorPos(6,11)
  204.       I1[3] = " X "
  205.       write(I1[3])
  206.       p1turn = false
  207.       term.setCursorPos(1,18)
  208.       term.setTextColor(colors.white)
  209.       write("Waiting for Player 2...")
  210.     elseif yPos == 13 and tonumber(I1[4]) == callnum then
  211.       term.setTextColor(colors.red)
  212.       term.setCursorPos(6,13)
  213.       I1[4] = " X "
  214.       write(I1[4])
  215.       p1turn = false
  216.       term.setCursorPos(1,18)
  217.       term.setTextColor(colors.white)
  218.       write("Waiting for Player 2...")
  219.     elseif yPos == 15 and tonumber(I1[5]) == callnum then
  220.       term.setTextColor(colors.red)
  221.       term.setCursorPos(6,15)
  222.       I1[5] = " X "
  223.       write(I1[5])
  224.       p1turn = false
  225.       term.setCursorPos(1,18)
  226.       term.setTextColor(colors.white)
  227.       write("Waiting for Player 2...")
  228.     end
  229.   elseif xPos >= 10 and xPos <= 12 then
  230.     if yPos == 7 and tonumber(N1[1]) == callnum then
  231.       term.setTextColor(colors.red)
  232.       term.setCursorPos(10,7)
  233.       N1[1] = " X "
  234.       write(N1[1])
  235.       p1turn = false
  236.       term.setCursorPos(1,18)
  237.       term.setTextColor(colors.white)
  238.       write("Waiting for Player 2...")
  239.     elseif yPos == 9 and tonumber(N1[2]) == callnum then
  240.       term.setTextColor(colors.red)
  241.       term.setCursorPos(10,9)
  242.       N1[2] = " X "
  243.       write(N1[2])
  244.       p1turn = false
  245.       term.setCursorPos(1,18)
  246.       term.setTextColor(colors.white)
  247.       write("Waiting for Player 2...")
  248.     elseif yPos == 11 and N1[3] == " F " then
  249.       term.setTextColor(colors.red)
  250.       term.setCursorPos(10,11)
  251.       N1[3] = " X "
  252.       write(N1[3])
  253.       p1turn = false
  254.       term.setCursorPos(1,18)
  255.       term.setTextColor(colors.white)
  256.       write("Waiting for Player 2...")
  257.     elseif yPos == 13 and tonumber(N1[4]) == callnum then
  258.       term.setTextColor(colors.red)
  259.       term.setCursorPos(10,13)
  260.       N1[4] = " X "
  261.       write(N1[4])
  262.       p1turn = false
  263.       term.setCursorPos(1,18)
  264.       term.setTextColor(colors.white)
  265.       write("Waiting for Player 2...")
  266.     elseif yPos == 15 and tonumber(N1[5]) == callnum then
  267.       term.setTextColor(colors.red)
  268.       term.setCursorPos(10,15)
  269.       N1[5] = " X "
  270.       write(N1[5])
  271.       p1turn = false
  272.       term.setCursorPos(1,18)
  273.       term.setTextColor(colors.white)
  274.       write("Waiting for Player 2...")
  275.     end
  276.   elseif xPos >= 14 and xPos <= 16 then
  277.     if yPos == 7 and tonumber(G1[1]) == callnum then
  278.       term.setTextColor(colors.red)
  279.       term.setCursorPos(14,7)
  280.       G1[1] = " X "
  281.       write(G1[1])
  282.       p1turn = false
  283.       term.setCursorPos(1,18)
  284.       term.setTextColor(colors.white)
  285.       write("Waiting for Player 2...")
  286.     elseif yPos == 9 and tonumber(G1[2]) == callnum then
  287.       term.setTextColor(colors.red)
  288.       term.setCursorPos(14,9)
  289.       G1[2] = " X "
  290.       write(G1[2])
  291.       p1turn = false
  292.       term.setCursorPos(1,18)
  293.       term.setTextColor(colors.white)
  294.       write("Waiting for Player 2...")
  295.     elseif yPos == 11 and tonumber(G1[3]) == callnum then
  296.       term.setTextColor(colors.red)
  297.       term.setCursorPos(14,11)
  298.       G1[3] = " X "
  299.       write(G1[3])
  300.       p1turn = false
  301.       term.setCursorPos(1,18)
  302.       term.setTextColor(colors.white)
  303.       write("Waiting for Player 2...")
  304.     elseif yPos == 13 and tonumber(G1[4]) == callnum then
  305.       term.setTextColor(colors.red)
  306.       term.setCursorPos(14,13)
  307.       G1[4] = " X "
  308.       write(G1[4])
  309.       p1turn = false
  310.       term.setCursorPos(1,18)
  311.       term.setTextColor(colors.white)
  312.       write("Waiting for Player 2...")
  313.     elseif yPos == 15 and tonumber(G1[5]) == callnum then
  314.       term.setTextColor(colors.red)
  315.       term.setCursorPos(14,15)
  316.       G1[5] = " X "
  317.       write(G1[5])
  318.       p1turn = false
  319.       term.setCursorPos(1,18)
  320.       term.setTextColor(colors.white)
  321.       write("Waiting for Player 2...")
  322.     end
  323.   elseif xPos >= 18 and xPos <= 20 then
  324.     if yPos == 7 and tonumber(O1[1]) == callnum then
  325.       term.setTextColor(colors.red)
  326.       term.setCursorPos(18,7)
  327.       O1[1] = " X "
  328.       write(O1[1])
  329.       p1turn = false
  330.       term.setCursorPos(1,18)
  331.       term.setTextColor(colors.white)
  332.       write("Waiting for Player 2...")
  333.     elseif yPos == 9 and tonumber(O1[2]) == callnum then
  334.       term.setTextColor(colors.red)
  335.       term.setCursorPos(18,9)
  336.       O1[2] = " X "
  337.       write(O1[2])
  338.       p1turn = false
  339.       term.setCursorPos(1,18)
  340.       term.setTextColor(colors.white)
  341.       write("Waiting for Player 2...")
  342.     elseif yPos == 11 and tonumber(O1[3]) == callnum then
  343.       term.setTextColor(colors.red)
  344.       term.setCursorPos(18,11)
  345.       O1[3] = " X "
  346.       write(O1[3])
  347.       p1turn = false
  348.       term.setCursorPos(1,18)
  349.       term.setTextColor(colors.white)
  350.       write("Waiting for Player 2...")
  351.     elseif yPos == 13 and tonumber(O1[4]) == callnum then
  352.       term.setTextColor(colors.red)
  353.       term.setCursorPos(18,13)
  354.       O1[4] = " X "
  355.       write(O1[4])
  356.       p1turn = false
  357.       term.setCursorPos(1,18)
  358.       term.setTextColor(colors.white)
  359.       write("Waiting for Player 2...")
  360.     elseif yPos == 15 and tonumber(O1[5]) == callnum then
  361.       term.setTextColor(colors.red)
  362.       term.setCursorPos(18,15)
  363.       O1[5] = " X "
  364.       write(O1[5])
  365.       p1turn = false
  366.       term.setCursorPos(1,18)
  367.       term.setTextColor(colors.white)
  368.       write("Waiting for Player 2...")
  369.     end
  370.   end
  371.   if xPos >= 9 and xPos <= 12 and yPos == 17 then
  372.     p1turn = false
  373.     term.setCursorPos(1,18)
  374.     term.setTextColor(colors.white)
  375.     write("Waiting for Player 2...")
  376.   end
  377. end
  378.  
  379. function aiinput()
  380.   sleep(2)
  381.   if tonumber(B2[1]) == callnum then
  382.     term.setTextColor(colors.red)
  383.     term.setCursorPos(26,7)
  384.     B2[1] = " X "
  385.     write(B2[1])
  386.     p2turn = false
  387.     term.setCursorPos(25,18)
  388.     term.setTextColor(colors.white)
  389.     write("Waiting for Player 1...")
  390.   elseif tonumber(B2[2]) == callnum then
  391.     term.setTextColor(colors.red)
  392.     term.setCursorPos(26,9)
  393.     B2[2] = " X "
  394.     write(B2[2])
  395.     p2turn = false
  396.     term.setCursorPos(25,18)
  397.     term.setTextColor(colors.white)
  398.     write("Waiting for Player 1...")
  399.   elseif tonumber(B2[3]) == callnum then
  400.     term.setTextColor(colors.red)
  401.     term.setCursorPos(26,11)
  402.     B2[3] = " X "
  403.     write(B2[3])
  404.     p2turn = false
  405.     term.setCursorPos(25,18)
  406.     term.setTextColor(colors.white)
  407.     write("Waiting for Player 1...")
  408.   elseif tonumber(B2[4]) == callnum then
  409.     term.setTextColor(colors.red)
  410.     term.setCursorPos(26,13)
  411.     B2[4] = " X "
  412.     write(B2[4])
  413.     p2turn = false
  414.     term.setCursorPos(25,18)
  415.     term.setTextColor(colors.white)
  416.     write("Waiting for Player 1...")
  417.   elseif tonumber(B2[5]) == callnum then
  418.     term.setTextColor(colors.red)
  419.     term.setCursorPos(26,15)
  420.     B2[5] = " X "
  421.     write(B2[5])
  422.     p2turn = false
  423.     term.setCursorPos(25,18)
  424.     term.setTextColor(colors.white)
  425.     write("Waiting for Player 1...")
  426.   elseif tonumber(I2[1]) == callnum then
  427.     term.setTextColor(colors.red)
  428.     term.setCursorPos(30,7)
  429.     I2[1] = " X "
  430.     write(I2[1])
  431.     p2turn = false
  432.     term.setCursorPos(25,18)
  433.     term.setTextColor(colors.white)
  434.     write("Waiting for Player 1...")
  435.   elseif tonumber(I2[2]) == callnum then
  436.     term.setTextColor(colors.red)
  437.     term.setCursorPos(30,9)
  438.     I2[2] = " X "
  439.     write(I2[2])
  440.     p2turn = false
  441.     term.setCursorPos(25,18)
  442.     term.setTextColor(colors.white)
  443.     write("Waiting for Player 1...")
  444.   elseif tonumber(I2[3]) == callnum then
  445.     term.setTextColor(colors.red)
  446.     term.setCursorPos(30,11)
  447.     I2[3] = " X "
  448.     write(I2[3])
  449.     p2turn = false
  450.     term.setCursorPos(25,18)
  451.     term.setTextColor(colors.white)
  452.     write("Waiting for Player 1...")
  453.   elseif tonumber(I2[4]) == callnum then
  454.     term.setTextColor(colors.red)
  455.     term.setCursorPos(30,13)
  456.     I2[4] = " X "
  457.     write(I2[4])
  458.     p2turn = false
  459.     term.setCursorPos(25,18)
  460.     term.setTextColor(colors.white)
  461.     write("Waiting for Player 1...")
  462.   elseif tonumber(I2[5]) == callnum then
  463.     term.setTextColor(colors.red)
  464.     term.setCursorPos(30,15)
  465.     I2[5] = " X "
  466.     write(I2[5])
  467.     p2turn = false
  468.     term.setCursorPos(25,18)
  469.     term.setTextColor(colors.white)
  470.     write("Waiting for Player 1...")
  471.   elseif tonumber(N2[1]) == callnum then
  472.     term.setTextColor(colors.red)
  473.     term.setCursorPos(34,7)
  474.     N2[1] = " X "
  475.     write(N2[1])
  476.     p2turn = false
  477.     term.setCursorPos(25,18)
  478.     term.setTextColor(colors.white)
  479.     write("Waiting for Player 1...")
  480.   elseif tonumber(N2[2]) == callnum then
  481.     term.setTextColor(colors.red)
  482.     term.setCursorPos(34,9)
  483.     N2[2] = " X "
  484.     write(N2[2])
  485.     p2turn = false
  486.     term.setCursorPos(25,18)
  487.     term.setTextColor(colors.white)
  488.     write("Waiting for Player 1...")
  489.   elseif tonumber(N2[4]) == callnum then
  490.     term.setTextColor(colors.red)
  491.     term.setCursorPos(34,13)
  492.     N2[4] = " X "
  493.     write(N2[4])
  494.     p2turn = false
  495.     term.setCursorPos(25,18)
  496.     term.setTextColor(colors.white)
  497.     write("Waiting for Player 1...")
  498.   elseif tonumber(N2[5]) == callnum then
  499.     term.setTextColor(colors.red)
  500.     term.setCursorPos(34,15)
  501.     N2[5] = " X "
  502.     write(N2[5])
  503.     p2turn = false
  504.     term.setCursorPos(25,18)
  505.     term.setTextColor(colors.white)
  506.     write("Waiting for Player 1...")
  507.   elseif tonumber(G2[1]) == callnum then
  508.     term.setTextColor(colors.red)
  509.     term.setCursorPos(38,7)
  510.     G2[1] = " X "
  511.     write(G2[1])
  512.     p2turn = false
  513.     term.setCursorPos(25,18)
  514.     term.setTextColor(colors.white)
  515.     write("Waiting for Player 1...")
  516.   elseif tonumber(G2[2]) == callnum then
  517.     term.setTextColor(colors.red)
  518.     term.setCursorPos(38,9)
  519.     G2[2] = " X "
  520.     write(G2[2])
  521.     p2turn = false
  522.     term.setCursorPos(25,18)
  523.     term.setTextColor(colors.white)
  524.     write("Waiting for Player 1...")
  525.   elseif tonumber(G2[3]) == callnum then
  526.     term.setTextColor(colors.red)
  527.     term.setCursorPos(38,11)
  528.     G2[3] = " X "
  529.     write(G2[3])
  530.     p2turn = false
  531.     term.setCursorPos(25,18)
  532.     term.setTextColor(colors.white)
  533.     write("Waiting for Player 1...")
  534.   elseif tonumber(G2[4]) == callnum then
  535.     term.setTextColor(colors.red)
  536.     term.setCursorPos(38,13)
  537.     G2[4] = " X "
  538.     write(G2[4])
  539.     p2turn = false
  540.     term.setCursorPos(25,18)
  541.     term.setTextColor(colors.white)
  542.     write("Waiting for Player 1...")
  543.   elseif tonumber(G2[5]) == callnum then
  544.     term.setTextColor(colors.red)
  545.     term.setCursorPos(38,15)
  546.     G2[5] = " X "
  547.     write(G2[5])
  548.     p2turn = false
  549.     term.setCursorPos(25,18)
  550.     term.setTextColor(colors.white)
  551.     write("Waiting for Player 1...")
  552.   elseif tonumber(O2[1]) == callnum then
  553.     term.setTextColor(colors.red)
  554.     term.setCursorPos(42,7)
  555.     O2[1] = " X "
  556.     write(O2[1])
  557.     p2turn = false
  558.     term.setCursorPos(25,18)
  559.     term.setTextColor(colors.white)
  560.     write("Waiting for Player 1...")
  561.   elseif tonumber(O2[2]) == callnum then
  562.     term.setTextColor(colors.red)
  563.     term.setCursorPos(42,9)
  564.     O2[2] = " X "
  565.     write(O2[2])
  566.     p2turn = false
  567.     term.setCursorPos(25,18)
  568.     term.setTextColor(colors.white)
  569.     write("Waiting for Player 1...")
  570.   elseif tonumber(O2[3]) == callnum then
  571.     term.setTextColor(colors.red)
  572.     term.setCursorPos(42,11)
  573.     O2[3] = " X "
  574.     write(O2[3])
  575.     p2turn = false
  576.     term.setCursorPos(25,18)
  577.     term.setTextColor(colors.white)
  578.     write("Waiting for Player 1...")
  579.   elseif tonumber(O2[4]) == callnum then
  580.     term.setTextColor(colors.red)
  581.     term.setCursorPos(42,13)
  582.     O2[4] = " X "
  583.     write(O2[4])
  584.     p2turn = false
  585.     term.setCursorPos(25,18)
  586.     term.setTextColor(colors.white)
  587.     write("Waiting for Player 1...")
  588.   elseif tonumber(O2[5]) == callnum then
  589.     term.setTextColor(colors.red)
  590.     term.setCursorPos(42,15)
  591.     O2[5] = " X "
  592.     write(O2[5])
  593.     p2turn = false
  594.     term.setCursorPos(25,18)
  595.     term.setTextColor(colors.white)
  596.     write("Waiting for Player 1...")
  597.   elseif N2[3] == " F " then
  598.     term.setTextColor(colors.red)
  599.     term.setCursorPos(34,11)
  600.     N2[3] = " X "
  601.     write(N2[3])
  602.     p2turn = false
  603.     term.setCursorPos(25,18)
  604.     term.setTextColor(colors.white)
  605.     write("Waiting for Player 1...")
  606.   else
  607.     p2turn = false
  608.     term.setCursorPos(25,18)
  609.     term.setTextColor(colors.white)
  610.     write("Waiting for Player 1...")
  611.    end
  612. end
  613.  
  614. function p2input()
  615.   if xPos >= 26 and xPos <= 28 then
  616.     if yPos == 7 and tonumber(B2[1]) == callnum then
  617.       term.setTextColor(colors.red)
  618.       term.setCursorPos(26,7)
  619.       B2[1] = " X "
  620.       write(B2[1])
  621.       p2turn = false
  622.       term.setCursorPos(25,18)
  623.       term.setTextColor(colors.white)
  624.       write("Waiting for Player 1...")
  625.     elseif yPos == 9 and tonumber(B2[2]) == callnum then
  626.       term.setTextColor(colors.red)
  627.       term.setCursorPos(26,9)
  628.       B2[2] = " X "
  629.       write(B2[2])
  630.       p2turn = false
  631.       term.setCursorPos(25,18)
  632.       term.setTextColor(colors.white)
  633.       write("Waiting for Player 1...")
  634.     elseif yPos == 11 and tonumber(B2[3]) == callnum then
  635.       term.setTextColor(colors.red)
  636.       term.setCursorPos(26,11)
  637.       B2[3] = " X "
  638.       write(B2[3])
  639.       p2turn = false
  640.       term.setCursorPos(25,18)
  641.       term.setTextColor(colors.white)
  642.       write("Waiting for Player 1...")
  643.     elseif yPos == 13 and tonumber(B2[4]) == callnum then
  644.       term.setTextColor(colors.red)
  645.       term.setCursorPos(26,13)
  646.       B2[4] = " X "
  647.       write(B2[4])
  648.       p2turn = false
  649.       term.setCursorPos(25,18)
  650.       term.setTextColor(colors.white)
  651.       write("Waiting for Player 1...")
  652.     elseif yPos == 15 and tonumber(B2[5]) == callnum then
  653.       term.setTextColor(colors.red)
  654.       term.setCursorPos(26,15)
  655.       B2[5] = " X "
  656.       write(B2[5])
  657.       p2turn = false
  658.       term.setCursorPos(25,18)
  659.       term.setTextColor(colors.white)
  660.       write("Waiting for Player 1...")
  661.     end
  662.   elseif xPos >= 30 and xPos <= 32 then
  663.     if yPos == 7 and tonumber(I2[1]) == callnum then
  664.       term.setTextColor(colors.red)
  665.       term.setCursorPos(30,7)
  666.       I2[1] = " X "
  667.       write(I2[1])
  668.       p2turn = false
  669.       term.setCursorPos(25,18)
  670.       term.setTextColor(colors.white)
  671.       write("Waiting for Player 1...")
  672.     elseif yPos == 9 and tonumber(I2[2]) == callnum then
  673.       term.setTextColor(colors.red)
  674.       term.setCursorPos(30,9)
  675.       I2[2] = " X "
  676.       write(I2[2])
  677.       p2turn = false
  678.       term.setCursorPos(25,18)
  679.       term.setTextColor(colors.white)
  680.       write("Waiting for Player 1...")
  681.     elseif yPos == 11 and tonumber(I2[3]) == callnum then
  682.       term.setTextColor(colors.red)
  683.       term.setCursorPos(30,11)
  684.       I2[3] = " X "
  685.       write(I2[3])
  686.       p2turn = false
  687.       term.setCursorPos(25,18)
  688.       term.setTextColor(colors.white)
  689.       write("Waiting for Player 1...")
  690.     elseif yPos == 13 and tonumber(I2[4]) == callnum then
  691.       term.setTextColor(colors.red)
  692.       term.setCursorPos(30,13)
  693.       I2[4] = " X "
  694.       write(I2[4])
  695.       p2turn = false
  696.       term.setCursorPos(25,18)
  697.       term.setTextColor(colors.white)
  698.       write("Waiting for Player 1...")
  699.     elseif yPos == 15 and tonumber(I2[5]) == callnum then
  700.       term.setTextColor(colors.red)
  701.       term.setCursorPos(30,15)
  702.       I2[5] = " X "
  703.       write(I2[5])
  704.       p2turn = false
  705.       term.setCursorPos(25,18)
  706.       term.setTextColor(colors.white)
  707.       write("Waiting for Player 1...")
  708.     end
  709.   elseif xPos >= 34 and xPos <= 36 then
  710.     if yPos == 7 and tonumber(N2[1]) == callnum then
  711.       term.setTextColor(colors.red)
  712.       term.setCursorPos(34,7)
  713.       N2[1] = " X "
  714.       write(N2[1])
  715.       p2turn = false
  716.       term.setCursorPos(25,18)
  717.       term.setTextColor(colors.white)
  718.       write("Waiting for Player 1...")
  719.     elseif yPos == 9 and tonumber(N2[2]) == callnum then
  720.       term.setTextColor(colors.red)
  721.       term.setCursorPos(34,9)
  722.       N2[2] = " X "
  723.       write(N2[2])
  724.       p2turn = false
  725.       term.setCursorPos(25,18)
  726.       term.setTextColor(colors.white)
  727.       write("Waiting for Player 1...")
  728.     elseif yPos == 11 and N2[3] == " F " then
  729.       term.setTextColor(colors.red)
  730.       term.setCursorPos(34,11)
  731.       N2[3] = " X "
  732.       write(N2[3])
  733.       p2turn = false
  734.       term.setCursorPos(25,18)
  735.       term.setTextColor(colors.white)
  736.       write("Waiting for Player 1...")
  737.     elseif yPos == 13 and tonumber(N2[4]) == callnum then
  738.       term.setTextColor(colors.red)
  739.       term.setCursorPos(34,13)
  740.       N2[4] = " X "
  741.       write(N2[4])
  742.       p2turn = false
  743.       term.setCursorPos(25,18)
  744.       term.setTextColor(colors.white)
  745.       write("Waiting for Player 1...")
  746.     elseif yPos == 15 and tonumber(N2[5]) == callnum then
  747.       term.setTextColor(colors.red)
  748.       term.setCursorPos(34,15)
  749.       N2[5] = " X "
  750.       write(N2[5])
  751.       p2turn = false
  752.       term.setCursorPos(25,18)
  753.       term.setTextColor(colors.white)
  754.       write("Waiting for Player 1...")
  755.     end
  756.   elseif xPos >= 38 and xPos <= 40 then
  757.     if yPos == 7 and tonumber(G2[1]) == callnum then
  758.       term.setTextColor(colors.red)
  759.       term.setCursorPos(38,7)
  760.       G2[1] = " X "
  761.       write(G2[1])
  762.       p2turn = false
  763.       term.setCursorPos(25,18)
  764.       term.setTextColor(colors.white)
  765.       write("Waiting for Player 1...")
  766.     elseif yPos == 9 and tonumber(G2[2]) == callnum then
  767.       term.setTextColor(colors.red)
  768.       term.setCursorPos(38,9)
  769.       G2[2] = " X "
  770.       write(G2[2])
  771.       p2turn = false
  772.       term.setCursorPos(25,18)
  773.       term.setTextColor(colors.white)
  774.       write("Waiting for Player 1...")
  775.     elseif yPos == 11 and tonumber(G2[3]) == callnum then
  776.       term.setTextColor(colors.red)
  777.       term.setCursorPos(38,11)
  778.       G2[3] = " X "
  779.       write(G2[3])
  780.       p2turn = false
  781.       term.setCursorPos(25,18)
  782.       term.setTextColor(colors.white)
  783.       write("Waiting for Player 1...")
  784.     elseif yPos == 13 and tonumber(G2[4]) == callnum then
  785.       term.setTextColor(colors.red)
  786.       term.setCursorPos(38,13)
  787.       G2[4] = " X "
  788.       write(G2[4])
  789.       p2turn = false
  790.       term.setCursorPos(25,18)
  791.       term.setTextColor(colors.white)
  792.       write("Waiting for Player 1...")
  793.     elseif yPos == 15 and tonumber(G2[5]) == callnum then
  794.       term.setTextColor(colors.red)
  795.       term.setCursorPos(38,15)
  796.       G2[5] = " X "
  797.       write(G2[5])
  798.       p2turn = false
  799.       term.setCursorPos(25,18)
  800.       term.setTextColor(colors.white)
  801.       write("Waiting for Player 1...")
  802.     end
  803.   elseif xPos >= 42 and xPos <= 44 then
  804.     if yPos == 7 and tonumber(O2[1]) == callnum then
  805.       term.setTextColor(colors.red)
  806.       term.setCursorPos(42,7)
  807.       O2[1] = " X "
  808.       write(O2[1])
  809.       p2turn = false
  810.       term.setCursorPos(25,18)
  811.       term.setTextColor(colors.white)
  812.       write("Waiting for Player 1...")
  813.     elseif yPos == 9 and tonumber(O2[2]) == callnum then
  814.       term.setTextColor(colors.red)
  815.       term.setCursorPos(42,9)
  816.       O2[2] = " X "
  817.       write(O2[2])
  818.       p2turn = false
  819.       term.setCursorPos(25,18)
  820.       term.setTextColor(colors.white)
  821.       write("Waiting for Player 1...")
  822.     elseif yPos == 11 and tonumber(O2[3]) == callnum then
  823.       term.setTextColor(colors.red)
  824.       term.setCursorPos(42,11)
  825.       O2[3] = " X "
  826.       write(O2[3])
  827.       p2turn = false
  828.       term.setCursorPos(25,18)
  829.       term.setTextColor(colors.white)
  830.       write("Waiting for Player 1...")
  831.     elseif yPos == 13 and tonumber(O2[4]) == callnum then
  832.       term.setTextColor(colors.red)
  833.       term.setCursorPos(42,13)
  834.       O2[4] = " X "
  835.       write(O2[4])
  836.       p2turn = false
  837.       term.setCursorPos(25,18)
  838.       term.setTextColor(colors.white)
  839.       write("Waiting for Player 1...")
  840.     elseif yPos == 15 and tonumber(O2[5]) == callnum then
  841.       term.setTextColor(colors.red)
  842.       term.setCursorPos(42,15)
  843.       O2[5] = " X "
  844.       write(O2[5])
  845.       p2turn = false
  846.       term.setCursorPos(25,18)
  847.       term.setTextColor(colors.white)
  848.       write("Waiting for Player 1...")
  849.     end
  850.   end
  851.   if xPos >= 33 and xPos <= 36 and yPos == 17 then
  852.     p2turn = false
  853.     term.setCursorPos(25,18)
  854.     term.setTextColor(colors.white)
  855.     write("Waiting for Player 1...")
  856.   end
  857. end
  858.  
  859. function inputs()
  860.   p1turn = true
  861.   p2turn = true
  862.   while true do
  863.     if p2game == true then
  864.       event, button, xPos, yPos = os.pullEvent()
  865.       if p1turn == true and xPos <= 21 then
  866.         if event == "mouse_click" and button == 1 then
  867.           p1input()
  868.         end
  869.       end
  870.       if p2turn == true and xPos >= 25 then
  871.         if event == "mouse_click" and button == 1 then
  872.           p2input()
  873.         end
  874.       end
  875.     else
  876.       if p1turn == true then
  877.         event, button, xPos, yPos = os.pullEvent()
  878.         if event == "mouse_click" and button == 1 then
  879.           p1input()
  880.         end
  881.       else
  882.         aiinput()
  883.       end
  884.     end
  885.     if p1turn == false and p2turn == false then
  886.       break
  887.     end
  888.   end
  889.   term.setCursorPos(1,18)
  890.   write("                                                  ")
  891. end
  892.  
  893. function wincheck()
  894.   if (B1[1] == " X " and B1[2] == " X " and B1[3] == " X " and B1[4] == " X " and B1[5] == " X ")
  895.   or (I1[1] == " X " and I1[2] == " X " and I1[3] == " X " and I1[4] == " X " and I1[5] == " X ")
  896.   or (N1[1] == " X " and N1[2] == " X " and N1[3] == " X " and N1[4] == " X " and N1[5] == " X ")
  897.   or (G1[1] == " X " and G1[2] == " X " and G1[3] == " X " and G1[4] == " X " and G1[5] == " X ")
  898.   or (O1[1] == " X " and O1[2] == " X " and O1[3] == " X " and O1[4] == " X " and O1[5] == " X ")
  899.   or (B1[1] == " X " and I1[1] == " X " and N1[1] == " X " and G1[1] == " X " and O1[1] == " X ")
  900.   or (B1[2] == " X " and I1[2] == " X " and N1[2] == " X " and G1[2] == " X " and O1[2] == " X ")
  901.   or (B1[3] == " X " and I1[3] == " X " and N1[3] == " X " and G1[3] == " X " and O1[3] == " X ")
  902.   or (B1[4] == " X " and I1[4] == " X " and N1[4] == " X " and G1[4] == " X " and O1[4] == " X ")
  903.   or (B1[5] == " X " and I1[5] == " X " and N1[5] == " X " and G1[5] == " X " and O1[5] == " X ")
  904.   or (B1[1] == " X " and I1[2] == " X " and N1[3] == " X " and G1[4] == " X " and O1[5] == " X ")
  905.   or (B1[5] == " X " and I1[4] == " X " and N1[3] == " X " and G1[2] == " X " and O1[1] == " X ") then
  906.     winner = 1
  907.   end
  908.   if (B2[1] == " X " and B2[2] == " X " and B2[3] == " X " and B2[4] == " X " and B2[5] == " X ")
  909.   or (I2[1] == " X " and I2[2] == " X " and I2[3] == " X " and I2[4] == " X " and I2[5] == " X ")
  910.   or (N2[1] == " X " and N2[2] == " X " and N2[3] == " X " and N2[4] == " X " and N2[5] == " X ")
  911.   or (G2[1] == " X " and G2[2] == " X " and G2[3] == " X " and G2[4] == " X " and G2[5] == " X ")
  912.   or (O2[1] == " X " and O2[2] == " X " and O2[3] == " X " and O2[4] == " X " and O2[5] == " X ")
  913.   or (B2[1] == " X " and I2[1] == " X " and N2[1] == " X " and G2[1] == " X " and O2[1] == " X ")
  914.   or (B2[2] == " X " and I2[2] == " X " and N2[2] == " X " and G2[2] == " X " and O2[2] == " X ")
  915.   or (B2[3] == " X " and I2[3] == " X " and N2[3] == " X " and G2[3] == " X " and O2[3] == " X ")
  916.   or (B2[4] == " X " and I2[4] == " X " and N2[4] == " X " and G2[4] == " X " and O2[4] == " X ")
  917.   or (B2[5] == " X " and I2[5] == " X " and N2[5] == " X " and G2[5] == " X " and O2[5] == " X ")
  918.   or (B2[1] == " X " and I2[2] == " X " and N2[3] == " X " and G2[4] == " X " and O2[5] == " X ")
  919.   or (B2[5] == " X " and I2[4] == " X " and N2[3] == " X " and G2[2] == " X " and O2[1] == " X ") then
  920.     if winner == 1 then
  921.       winner = 3
  922.     else
  923.       winner = 2
  924.     end
  925.   end
  926. end
  927.  
  928. wins = 0
  929. losses = 0
  930. draws1 = 0
  931.  
  932. player1 = 0
  933. player2 = 0
  934. draws2 = 0
  935. if fs.exists("bingo/stats") then
  936.   stats = fs.open("bingo/stats","r")
  937.   wins = stats.readLine()
  938.   losses = stats.readLine()
  939.   draws1 = stats.readLine()
  940.   player1 = stats.readLine()
  941.   player2 = stats.readLine()
  942.   draws2 = stats.readLine()
  943.   stats.close()
  944. end
  945.  
  946. p1game = true
  947. p2game = false
  948. term.clear()
  949. term.setCursorPos(1,1)
  950. print("BingoCraft by theTANCO.")
  951. print("")
  952. print("[ 1 Player Game ]")
  953. print("  2 Player Game  ")
  954. print("")
  955. print("Select an Option and press Enter to begin.")
  956. while true do
  957.   event, key = os.pullEvent("key")
  958.   if key == 208 then
  959.     term.setCursorPos(1,3)
  960.     print("  1 Player Game  ")
  961.     print("[ 2 Player Game ]")
  962.     p1game = false
  963.     p2game = true
  964.   elseif key == 200 then
  965.     term.setCursorPos(1,3)
  966.     print("[ 1 Player Game ]")
  967.     print("  2 Player Game  ")
  968.     p1game = true
  969.     p2game = false
  970.   elseif key == 28 or key == 156 then
  971.     term.setCursorPos(1,8)
  972.     print("")
  973.     print("Loading...")
  974.     break
  975.   end
  976. end
  977.  
  978. bingoboards()
  979. B1 = B
  980. I1 = I
  981. N1 = N
  982. G1 = G
  983. O1 = O
  984. bingoboards()
  985. B2 = B
  986. I2 = I
  987. N2 = N
  988. G2 = G
  989. O2 = O
  990.  
  991. winner = 0
  992.  
  993. term.clear()
  994. setboards()
  995. for g=1,100 do
  996.   callnums()
  997.   inputs()
  998.   wincheck()
  999.   if winner > 0 then
  1000.     break
  1001.   end
  1002. end
  1003.  
  1004. stats = fs.open("bingo/stats","w")
  1005. if winner == 0 then
  1006.   winner = 3
  1007. end
  1008. if p2game == true then
  1009.   if winner == 1 then
  1010.     player1 = player1 + 1
  1011.   end
  1012.   if winner == 2 then
  1013.     player2 = player2 + 1
  1014.   end
  1015.   if winner == 3 then
  1016.     draws2 = draws2 + 1
  1017.   end
  1018. else
  1019.   if winner == 1 then
  1020.     wins = wins + 1
  1021.   end
  1022.   if winner == 2 then
  1023.     losses = losses + 1
  1024.   end
  1025.   if winner == 3 then
  1026.     draws1 = draws1 + 1
  1027.   end
  1028. end
  1029. stats.writeLine(wins)
  1030. stats.writeLine(losses)
  1031. stats.writeLine(draws1)
  1032. stats.writeLine(player1)
  1033. stats.writeLine(player2)
  1034. stats.writeLine(draws2)
  1035. stats.close()
  1036.  
  1037. term.setTextColor(colors.white)
  1038. term.setCursorPos(1,18)
  1039. if winner == 3 then
  1040.   print("Game over! It's a draw!                           ")
  1041. elseif winner > 0 and winner < 3 then
  1042.   print("Game over! Player "..winner.." wins!                         ")
  1043. end
  1044. print("Press Enter to end game or Space to start new game.")
  1045. write("Press S to see stats or R to reset stats.")
  1046. viewingstats = true
  1047. resetting = true
  1048. while true do
  1049.   event, button = os.pullEvent("key")
  1050.   if button == 28 or button == 156 or button == 57 then
  1051.     break
  1052.   elseif button == 31 and viewingstats == true then
  1053.     term.clear()
  1054.     term.setCursorPos(1,1)
  1055.     print("Win/Loss Statistics")
  1056.     print("")
  1057.     print("1 Player Games")
  1058.     print("Wins: "..math.floor(wins))
  1059.     print("Losses: "..math.floor(losses))
  1060.     print("Draws: "..math.floor(draws1))
  1061.     p1games = wins + losses + draws1
  1062.     print("Games Played: "..math.floor(p1games))
  1063.     print("")
  1064.     print("2 Player Games")
  1065.     print("Player 1: "..math.floor(player1))
  1066.     print("Player 2: "..math.floor(player2))
  1067.     print("Draws: "..math.floor(draws2))
  1068.     p2games = player1 + player2 + draws2
  1069.     print("Games Played: "..math.floor(p2games))
  1070.     print("")
  1071.     print("Press Enter to end game or Space to start new game.")
  1072.     write("Press R to reset stats.")
  1073.     viewingstats = false
  1074.   elseif button == 19 and resetting == true then
  1075.     fs.delete("bingo/stats")
  1076.     wins = 0
  1077.     losses = 0
  1078.     draws1 = 0
  1079.     player1 = 0
  1080.     player2 = 0
  1081.     draws2 = 0
  1082.     if viewingstats == false then
  1083.       term.clear()
  1084.       term.setCursorPos(1,1)
  1085.       print("Win/Loss Statistics")
  1086.       print("")
  1087.       print("1 Player Games")
  1088.       print("Wins: "..tostring(wins))
  1089.       print("Losses: "..tostring(losses))
  1090.       print("Draws: "..tostring(draws1))
  1091.       p1games = wins + losses + draws1
  1092.       print("Games Played: "..tostring(p1games))
  1093.       print("")
  1094.       print("2 Player Games")
  1095.       print("Player 1: "..tostring(player1))
  1096.       print("Player 2: "..tostring(player2))
  1097.       print("Draws: "..tostring(draws2))
  1098.       p2games = player1 + player2 + draws2
  1099.       print("Games Played: "..tostring(p2games))
  1100.       print("")
  1101.       print("Press Enter to end game or Space to start new game.")
  1102.       write("Press R to reset stats.")
  1103.     end
  1104.     write("\nStats reset.")
  1105.     resetting = false
  1106.   end
  1107. end
  1108. if button == 57 then
  1109.   shell.run("restartgame")
  1110. elseif button == 28 or button == 156 then
  1111.   shell.run("clear")
  1112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement