Guest User

connectthree

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