Guest User

connectthree

a guest
Dec 11th, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.94 KB | None | 0 0
  1. chat = peripheral.wrap("front")
  2. rednet.open("right")
  3. local grid = {}
  4. turns = {a,ab, aa, commandNum, commandNumTwo }
  5. win = {
  6.   {1,2,3},
  7.   {1,6,11},
  8.   {1,7,13},
  9.   {2,7,12},
  10.   {2,8,14},
  11.   {2,3,4},
  12.   {3,7,11},
  13.   {3,8,13},
  14.   {3,4,5},
  15.   {3,9,15},
  16.   {4,9,14},
  17.   {4,8,12},
  18.   {5,10,15},
  19.   {5,9,13},
  20.   {6,7,8},
  21.   {6,11,16},
  22.   {6,12,18},
  23.   {7,8,9},
  24.   {7,12,17},
  25.   {7,13,19},
  26.   {8,13,18},
  27.   {8,14,20},
  28.   {8,12,16},
  29.   {8,9,10},
  30.   {9,14,19},
  31.   {9,13,17},
  32.   {10,14,18},
  33.   {10,15,20},
  34.   {11,12,13},
  35.   {11,16,21},
  36.   {11,17,23},
  37.   {12,13,14},
  38.   {12,17,22},
  39.   {12,18,24},
  40.   {13,14,15},
  41.   {13,18,23},
  42.   {13,19,25},
  43.   {14,19,24},
  44.   {14,28,24},
  45.   {15,20,25},
  46.   {15,19,23},
  47.   {16,17,18},
  48.   {17,18,19},
  49.   {18,19,20},
  50.   {21,22,23},
  51.   {22,23,24},
  52.   {23,24,25},
  53. }      
  54.  a = math.random(1,5)
  55.    local function doCommand(a)
  56.      if a == 1 then
  57.        redstone.setOutput("back", true)
  58.       elseif a==2 then
  59.         redstone.setOutput("top", true)
  60.        elseif a == 3 then
  61.          redstone.setOutput("left", true)
  62.         elseif a == 4 then
  63.           redstone.setOutput("bottom", true)
  64.          elseif a == 5 then
  65.            rednet.send(52, "redstone5", "redstone5")
  66.          elseif a == 6 then
  67.            rednet.send(51, "redstone6", "redstone6")
  68.          elseif a == 7 then
  69.            rednet.send(53, "redstone7","redstone7")
  70.          elseif a == 8 then
  71.            rednet.send(55, "redstone", "redstone8")
  72.          elseif a == 9 then
  73.            rednet.send(54, "redstone", "redstone9")
  74.          elseif a == 10 then
  75.            rednet.send(56, "redstone", "redstone10")
  76.          elseif a == 11 then
  77.            rednet.send(61, "redstone", "redstone11")
  78.          elseif a==  12 then
  79.            rednet.send(60, "redstone12", "redstone12")
  80.          elseif a == 13 then
  81.            rednet.send(59, "redstone13", "redstone13")
  82.          elseif a == 14 then
  83.            rednet.send(58, "redstone14", "redstone14")
  84.          elseif a == 15 then
  85.            rednet.send(57, "redstone15", "redstone15")
  86.          elseif a == 16 then
  87.            rednet.send(65, "redstone16", "redstone16")
  88.          elseif a == 17 then
  89.            rednet.send(67, "redstone17", "redstone17")
  90.          elseif a == 18 then
  91.            rednet.send(68, "redstone18", "redstone18")
  92.          elseif a == 19 then
  93.            rednet.send(69, "redstone19", "redstone19")
  94.          elseif a == 20 then
  95.            rednet.send(70, "redstone20", "redstone20")
  96.          elseif a == 21 then
  97.            rednet.send(66, "redstone21", "redstone21")
  98.          elseif a == 22 then
  99.            rednet.send(71, "redstone22", "redstone22")
  100.          else if a == 23 then
  101.            rednet.send(72, "redstone23", "redstone23")
  102.          elseif a == 24 then
  103.            rednet.send(73, "redstone24", "redstone24")
  104.          elseif a == 25 then
  105.            rednet.send(74, "redstone25", "redstone25")                        
  106.        end
  107.    end
  108.  end  
  109.     sleep(2)                            
  110. chat.say("Ok, I'm going in spot "..a)
  111.  
  112. doCommand(a)
  113. grid[a] = true
  114. moves = 0
  115.  
  116. moves = moves + 1
  117.  
  118. sleep(2)
  119. chat.say("What space would you like to go to?")
  120. local commandNum
  121. repeat
  122.   local player, event, command= os.pullEvent("chat")
  123.   commandNum = tonumber(command:match("%d+"))
  124.   until commandNum and commandNum> 0 and commandNum<12
  125.  
  126. sleep(2)
  127.  
  128. doCommand(commandNum)
  129. grid[commandNum] = true
  130.  
  131. sleep(2)
  132. topBottom = math.random(1,2)
  133. print("This is top bottom: "..topBottom)
  134. chat.say("Alright, my turn again.")
  135. if topBottom == 1 then
  136.   repeat
  137.     aa = math.random(1,5)
  138.     until aa~= a and aa ~= command
  139.     sleep(2)
  140.     chat.say("I will go to spot "..aa)
  141.  
  142.  
  143. elseif topBottom == 2 then
  144.  
  145.  if commandNum == a +5 then
  146. aa = commandNum +5
  147. sleep(2)
  148. chat.say("I will go to spot "..aa)
  149. elseif commandNum ~= a+5 then
  150.           aa = a+5
  151.         sleep(2)
  152.         chat.say("I will go to spot "..aa)
  153.   end
  154.  end    
  155.  doCommand(aa)
  156.  grid[aa] = true
  157.      sleep(2)
  158.  chat.say("Ok, your turn again!Where would you like to go?")
  159.    local commandNumTwo
  160.     repeat
  161.       player, event, commandTwo = os.pullEvent("chat")
  162.       commandNumTwo = tonumber(commandTwo:match("%d+"))
  163.       until commandNumTwo and commandNumTwo > 0 and commandNumTwo <21
  164.        
  165.       sleep(2)
  166.        
  167.       doCommand(commandNumTwo)
  168.       grid[commandNumTwo] = true
  169.        
  170.  topBottom2 = math.random(1,1)
  171.      
  172.  chat.say("Time for me to go again.")
  173.      if topBottom2 == 1 then
  174.        repeat
  175.          ab = math.random(1,5)
  176.          until ab~= a and ab~=commandNum and ab~=aa and ab ~= commandNumTwo
  177.    sleep(2)
  178.    chat.say("I will go to spot "..ab)    
  179.        end
  180.    doCommand(ab)    
  181.     sleep(2)    
  182.  if  win == turns[1] and turns[2] and turns[3] and turns[4] and turns[5] then
  183.  chat.say("You win!")
  184.  end
  185. sleep(2)      
  186.  chat.say("Would you like to play again?")
  187.  sleep(2)
  188.  player, event, reboot = os.pullEvent("chat")
  189.  if string.match(reboot, "yes") then
  190.  rednet.send(52, "redstone5r", "redstone5r")
  191.  rednet.send(51, "redstone6r", "redstone6r")
  192.  rednet.send(53, "redstone7r", "redstone7r")
  193.  rednet.send(55, "redstone8r", "redstone8r")
  194.  rednet.send(54, "redstone9r", "redstone9r")
  195.  rednet.send(56, "redstone10r", "redstone10r")
  196.  rednet.send(61, "redstone11r", "redstone11r")
  197.  rednet.send(60, "redstone12r", "redstone12r")
  198.  rednet.send(59, "redstone13r", "redstone13r")
  199.  rednet.send(58, "redstone14r", "redstone14r")
  200.  rednet.send(57, "redstone15r", "redstone15r")
  201.  rednet.send(65, "redstone16r", "redstone16r")
  202.  rednet.send(67, "redstone17r", "redstone17r")
  203.  rednet.send(68, "redstone18r", "redstone18r")
  204.  rednet.send(69, "redstone19r", "redstone19r")
  205.  rednet.send(70, "redstone20r", "redstone20r")
  206.  rednet.send(66, "redstone21r", "redstone21r")
  207.  rednet.send(71, "redstone22r", "redstone22r")
  208.  rednet.send(72, "redstone23r", "redstone23r")
  209.  rednet.send(73, "redstone24r", "redstone24r")
  210.  rednet.send(74, "redstone25r", "redstone25r")
  211.  os.reboot()
  212.  end
Advertisement
Add Comment
Please, Sign In to add comment