Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chat = peripheral.wrap("front")
- rednet.open("right")
- local grid = {}
- turns = {a,ab, aa, commandNum, commandNumTwo }
- win = {
- {1,2,3},
- {1,6,11},
- {1,7,13},
- {2,7,12},
- {2,8,14},
- {2,3,4},
- {3,7,11},
- {3,8,13},
- {3,4,5},
- {3,9,15},
- {4,9,14},
- {4,8,12},
- {5,10,15},
- {5,9,13},
- {6,7,8},
- {6,11,16},
- {6,12,18},
- {7,8,9},
- {7,12,17},
- {7,13,19},
- {8,13,18},
- {8,14,20},
- {8,12,16},
- {8,9,10},
- {9,14,19},
- {9,13,17},
- {10,14,18},
- {10,15,20},
- {11,12,13},
- {11,16,21},
- {11,17,23},
- {12,13,14},
- {12,17,22},
- {12,18,24},
- {13,14,15},
- {13,18,23},
- {13,19,25},
- {14,19,24},
- {14,28,24},
- {15,20,25},
- {15,19,23},
- {16,17,18},
- {17,18,19},
- {18,19,20},
- {21,22,23},
- {22,23,24},
- {23,24,25},
- }
- a = math.random(1,5)
- local function doCommand(a)
- if a == 1 then
- redstone.setOutput("back", true)
- elseif a==2 then
- redstone.setOutput("top", true)
- elseif a == 3 then
- redstone.setOutput("left", true)
- elseif a == 4 then
- redstone.setOutput("bottom", true)
- elseif a == 5 then
- rednet.send(52, "redstone5", "redstone5")
- elseif a == 6 then
- rednet.send(51, "redstone6", "redstone6")
- elseif a == 7 then
- rednet.send(53, "redstone7","redstone7")
- elseif a == 8 then
- rednet.send(55, "redstone", "redstone8")
- elseif a == 9 then
- rednet.send(54, "redstone", "redstone9")
- elseif a == 10 then
- rednet.send(56, "redstone", "redstone10")
- elseif a == 11 then
- rednet.send(61, "redstone", "redstone11")
- elseif a== 12 then
- rednet.send(60, "redstone12", "redstone12")
- elseif a == 13 then
- rednet.send(59, "redstone13", "redstone13")
- elseif a == 14 then
- rednet.send(58, "redstone14", "redstone14")
- elseif a == 15 then
- rednet.send(57, "redstone15", "redstone15")
- elseif a == 16 then
- rednet.send(65, "redstone16", "redstone16")
- elseif a == 17 then
- rednet.send(67, "redstone17", "redstone17")
- elseif a == 18 then
- rednet.send(68, "redstone18", "redstone18")
- elseif a == 19 then
- rednet.send(69, "redstone19", "redstone19")
- elseif a == 20 then
- rednet.send(70, "redstone20", "redstone20")
- elseif a == 21 then
- rednet.send(66, "redstone21", "redstone21")
- elseif a == 22 then
- rednet.send(71, "redstone22", "redstone22")
- else if a == 23 then
- rednet.send(72, "redstone23", "redstone23")
- elseif a == 24 then
- rednet.send(73, "redstone24", "redstone24")
- elseif a == 25 then
- rednet.send(74, "redstone25", "redstone25")
- end
- end
- end
- sleep(2)
- chat.say("Ok, I'm going in spot "..a)
- doCommand(a)
- grid[a] = true
- moves = 0
- moves = moves + 1
- sleep(2)
- chat.say("What space would you like to go to?")
- local commandNum
- repeat
- local player, event, command= os.pullEvent("chat")
- commandNum = tonumber(command:match("%d+"))
- until commandNum and commandNum> 0 and commandNum<12
- sleep(2)
- doCommand(commandNum)
- grid[commandNum] = true
- sleep(2)
- topBottom = math.random(1,2)
- print("This is top bottom: "..topBottom)
- chat.say("Alright, my turn again.")
- if topBottom == 1 then
- repeat
- aa = math.random(1,5)
- until aa~= a and aa ~= command
- sleep(2)
- chat.say("I will go to spot "..aa)
- elseif topBottom == 2 then
- if commandNum == a +5 then
- aa = commandNum +5
- sleep(2)
- chat.say("I will go to spot "..aa)
- elseif commandNum ~= a+5 then
- aa = a+5
- sleep(2)
- chat.say("I will go to spot "..aa)
- end
- end
- doCommand(aa)
- grid[aa] = true
- sleep(2)
- chat.say("Ok, your turn again!Where would you like to go?")
- local commandNumTwo
- repeat
- player, event, commandTwo = os.pullEvent("chat")
- commandNumTwo = tonumber(commandTwo:match("%d+"))
- until commandNumTwo and commandNumTwo > 0 and commandNumTwo <21
- sleep(2)
- doCommand(commandNumTwo)
- grid[commandNumTwo] = true
- topBottom2 = math.random(1,1)
- chat.say("Time for me to go again.")
- if topBottom2 == 1 then
- repeat
- ab = math.random(1,5)
- until ab~= a and ab~=commandNum and ab~=aa and ab ~= commandNumTwo
- sleep(2)
- chat.say("I will go to spot "..ab)
- end
- doCommand(ab)
- sleep(2)
- if win == turns[1] and turns[2] and turns[3] and turns[4] and turns[5] then
- chat.say("You win!")
- end
- sleep(2)
- chat.say("Would you like to play again?")
- sleep(2)
- player, event, reboot = os.pullEvent("chat")
- if string.match(reboot, "yes") then
- rednet.send(52, "redstone5r", "redstone5r")
- rednet.send(51, "redstone6r", "redstone6r")
- rednet.send(53, "redstone7r", "redstone7r")
- rednet.send(55, "redstone8r", "redstone8r")
- rednet.send(54, "redstone9r", "redstone9r")
- rednet.send(56, "redstone10r", "redstone10r")
- rednet.send(61, "redstone11r", "redstone11r")
- rednet.send(60, "redstone12r", "redstone12r")
- rednet.send(59, "redstone13r", "redstone13r")
- rednet.send(58, "redstone14r", "redstone14r")
- rednet.send(57, "redstone15r", "redstone15r")
- rednet.send(65, "redstone16r", "redstone16r")
- rednet.send(67, "redstone17r", "redstone17r")
- rednet.send(68, "redstone18r", "redstone18r")
- rednet.send(69, "redstone19r", "redstone19r")
- rednet.send(70, "redstone20r", "redstone20r")
- rednet.send(66, "redstone21r", "redstone21r")
- rednet.send(71, "redstone22r", "redstone22r")
- rednet.send(72, "redstone23r", "redstone23r")
- rednet.send(73, "redstone24r", "redstone24r")
- rednet.send(74, "redstone25r", "redstone25r")
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment