Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Rubik's Cube made by VikeStep
- -- 1: Blue, 2: Red, 3: Green, 4: Orange, 5: Yellow, 6: White
- -- f: front, r: right, b: back, l: left, u: up, d: down
- -- id 117 is replaced with 220 due to accidental breakage
- local f, r, b, l, u, d = {}, {}, {}, {}, {}, {}
- local rubiksvars
- local nomove = false
- function split(pString, pPattern)
- numchanged = 0
- local Table = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pPattern
- local last_end = 1
- local s, e, cap = pString:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- numchanged = numchanged +1
- end
- last_end = e+1
- s, e, cap = pString:find(fpat, last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table, cap)
- numchanged = numchanged +1
- end
- return Table
- end
- function loadCube()
- if fs.exists("rubiksvariables") then
- loadVariables()
- for i = 1,9 do
- f[i] = rubiksvars[i]
- r[i] = rubiksvars[i+9]
- b[i] = rubiksvars[i+18]
- l[i] = rubiksvars[i+27]
- u[i] = rubiksvars[i+36]
- d[i] = rubiksvars[i+45]
- end
- else
- for i = 1,9 do
- f[i] = 1
- r[i] = 2
- b[i] = 3
- l[i] = 4
- u[i] = 5
- d[i] = 6
- end
- end
- end
- function loadVariables()
- local file = fs.open("rubiksvariables","r")
- rubiksvars = split(file.readLine(), "@")
- file.close()
- end
- function saveVariables(variables)
- local file = fs.open("rubiksvariables","w")
- file.writeLine(variables)
- file.close()
- end
- function positionToID(position)
- local id
- if position == "f" then
- id = "0,1,2,3"
- elseif position == "fl" then
- id = "4,5,6,7"
- elseif position == "fr" then
- id = "8,9,10,11"
- elseif position == "fu" then
- id = "12,13,14,15"
- elseif position == "fd" then
- id = "16,17,18,19"
- elseif position == "fru" then
- id = "20,21,22,23"
- elseif position == "flu" then
- id = "24,25,26,27"
- elseif position == "fdr" then
- id = "28,29,30,31"
- elseif position == "fdl" then
- id = "32,33,34,35"
- elseif position == "r" then
- id = "36,37,38,39"
- elseif position == "rf" then
- id = "40,41,42,43"
- elseif position == "rb" then
- id = "44,45,46,47"
- elseif position == "ru" then
- id = "48,49,50,51"
- elseif position == "rd" then
- id = "52,53,54,55"
- elseif position == "rbu" then
- id = "56,57,58,59"
- elseif position == "rfu" then
- id = "60,61,62,63"
- elseif position == "rbd" then
- id = "64,65,66,67"
- elseif position == "rdf" then
- id = "68,69,70,71"
- elseif position == "b" then
- id = "72,73,74,75"
- elseif position == "br" then
- id = "76,77,78,79"
- elseif position == "bl" then
- id = "80,81,82,83"
- elseif position == "bu" then
- id = "84,85,86,87"
- elseif position == "bd" then
- id = "88,89,90,91"
- elseif position == "blu" then
- id = "92,93,94,95"
- elseif position == "bru" then
- id = "96,97,98,99"
- elseif position == "bdl" then
- id = "100,101,102,103"
- elseif position == "bdr" then
- id = "104,105,106,107"
- elseif position == "l" then
- id = "108,109,110,111"
- elseif position == "lb" then
- id = "112,113,114,115"
- elseif position == "lf" then
- id = "116,117,220,119"
- elseif position == "lu" then
- id = "120,121,122,123"
- elseif position == "ld" then
- id = "124,125,126,127"
- elseif position == "lfu" then
- id = "128,129,130,131"
- elseif position == "lbu" then
- id = "132,133,134,135"
- elseif position == "ldf" then
- id = "136,137,138,139"
- elseif position == "lbd" then
- id = "140,141,142,143"
- elseif position == "u" then
- id = "144,145,146,147"
- elseif position == "ul" then
- id = "148,149,150,151"
- elseif position == "ur" then
- id = "152,153,154,155"
- elseif position == "ub" then
- id = "156,157,158,159"
- elseif position == "uf" then
- id = "160,161,162,163"
- elseif position == "ubr" then
- id = "164,165,166,167"
- elseif position == "ubl" then
- id = "168,169,170,171"
- elseif position == "ufr" then
- id = "172,173,174,175"
- elseif position == "ufl" then
- id = "176,177,178,179"
- elseif position == "d" then
- id = "180,181,182,183"
- elseif position == "dl" then
- id = "184,185,186,187"
- elseif position == "dr" then
- id = "188,189,190,191"
- elseif position == "df" then
- id = "192,193,194,195"
- elseif position == "db" then
- id = "196,197,198,199"
- elseif position == "dfr" then
- id = "200,201,202,203"
- elseif position == "dfl" then
- id = "204,205,206,207"
- elseif position == "dbr" then
- id = "208,209,210,211"
- elseif position == "dbl" then
- id = "212,213,214,215"
- else
- print("error, incorrect position")
- end
- return split(id,",")
- end
- function setup()
- loadCube()
- rednet.open("right")
- end
- function saveCube()
- local tempsave = tostring(f[1]).."@"
- for i = 2,9 do
- tempsave = tempsave..tostring(f[i]).."@"
- end
- for i = 1,9 do
- tempsave = tempsave..tostring(r[i]).."@"
- end
- for i = 1,9 do
- tempsave = tempsave..tostring(b[i]).."@"
- end
- for i = 1,9 do
- tempsave = tempsave..tostring(l[i]).."@"
- end
- for i = 1,9 do
- tempsave = tempsave..tostring(u[i]).."@"
- end
- for i = 1,8 do
- tempsave = tempsave..tostring(d[i]).."@"
- end
- tempsave = tempsave..tostring(d[9])
- saveVariables(tempsave)
- end
- function send(id, colour)
- local side
- id = tonumber(id)
- if id <= 143 then
- side = "f"
- elseif id >= 144 and id <=179 then
- side = "t"
- elseif id >=180 and id <=215 then
- side = "d"
- elseif id == 220 then
- side = "f"
- else
- print("type in the side this id is facing: u, f or d")
- side = read()
- end
- rednet.send(id, side..","..tostring(colour))
- end
- function resetCube()
- for i = 0, 35 do
- send(i, 1)
- end
- for i = 36, 71 do
- send(i, 2)
- end
- for i = 72, 107 do
- send(i, 3)
- end
- for i = 108, 143 do
- send(i, 4)
- end
- for i = 144, 179 do
- send(i, 5)
- end
- for i = 180, 215 do
- send(i, 6)
- end
- send(220, 4)
- for i = 1,9 do
- f[i] = 1
- r[i] = 2
- b[i] = 3
- l[i] = 4
- u[i] = 5
- d[i] = 6
- end
- end
- function sendSquare(side, colour)
- local ids
- if nomove == false then
- ids = positionToID(side)
- for i = 1, 4 do
- send(ids[i], colour)
- end
- end
- saveColour(side, colour)
- end
- function readInput()
- while true do
- local id, msg = rednet.receive()
- if msg == "reset" then
- resetCube()
- elseif msg == "F" then
- moveF()
- elseif msg == "R" then
- moveR()
- elseif msg == "B" then
- moveB()
- elseif msg == "L" then
- moveL()
- elseif msg == "U" then
- moveU()
- elseif msg == "D" then
- moveD()
- elseif msg == "F'" then
- nomove = true
- moveF()
- moveF()
- nomove = false
- moveF()
- elseif msg == "R'" then
- nomove = true
- moveR()
- moveR()
- nomove = false
- moveR()
- elseif msg == "B'" then
- nomove = true
- moveB()
- moveB()
- nomove = false
- moveB()
- elseif msg == "L'" then
- nomove = true
- moveL()
- moveL()
- nomove = false
- moveL()
- elseif msg == "U'" then
- nomove = true
- moveU()
- moveU()
- nomove = false
- moveU()
- elseif msg == "D'" then
- nomove = true
- moveD()
- moveD()
- nomove = false
- moveD()
- elseif msg == "randomise" then
- randomise()
- end
- end
- end
- function getColour(position)
- local colour
- if position == "f" then
- colour = f[5]
- elseif position == "fl" then
- colour = f[4]
- elseif position == "fr" then
- colour = f[6]
- elseif position == "fu" then
- colour = f[2]
- elseif position == "fd" then
- colour = f[8]
- elseif position == "fru" then
- colour = f[3]
- elseif position == "flu" then
- colour = f[1]
- elseif position == "fdr" then
- colour = f[9]
- elseif position == "fdl" then
- colour = f[7]
- elseif position == "r" then
- colour = r[5]
- elseif position == "rf" then
- colour = r[4]
- elseif position == "rb" then
- colour = r[6]
- elseif position == "ru" then
- colour = r[2]
- elseif position == "rd" then
- colour = r[8]
- elseif position == "rbu" then
- colour = r[3]
- elseif position == "rfu" then
- colour = r[1]
- elseif position == "rbd" then
- colour = r[9]
- elseif position == "rdf" then
- colour = r[7]
- elseif position == "b" then
- colour = b[5]
- elseif position == "br" then
- colour = b[4]
- elseif position == "bl" then
- colour = b[6]
- elseif position == "bu" then
- colour = b[2]
- elseif position == "bd" then
- colour = b[8]
- elseif position == "blu" then
- colour = b[3]
- elseif position == "bru" then
- colour = b[1]
- elseif position == "bdl" then
- colour = b[9]
- elseif position == "bdr" then
- colour = b[7]
- elseif position == "l" then
- colour = l[5]
- elseif position == "lb" then
- colour = l[4]
- elseif position == "lf" then
- colour = l[6]
- elseif position == "lu" then
- colour = l[2]
- elseif position == "ld" then
- colour = l[8]
- elseif position == "lfu" then
- colour = l[3]
- elseif position == "lbu" then
- colour = l[1]
- elseif position == "ldf" then
- colour = l[9]
- elseif position == "lbd" then
- colour = l[7]
- elseif position == "u" then
- colour = u[5]
- elseif position == "ul" then
- colour = u[4]
- elseif position == "ur" then
- colour = u[6]
- elseif position == "ub" then
- colour = u[2]
- elseif position == "uf" then
- colour = u[8]
- elseif position == "ubr" then
- colour = u[3]
- elseif position == "ubl" then
- colour = u[1]
- elseif position == "ufr" then
- colour = u[9]
- elseif position == "ufl" then
- colour = u[7]
- elseif position == "d" then
- colour = d[5]
- elseif position == "dl" then
- colour = d[4]
- elseif position == "dr" then
- colour = d[6]
- elseif position == "df" then
- colour = d[2]
- elseif position == "db" then
- colour = d[8]
- elseif position == "dfr" then
- colour = d[3]
- elseif position == "dfl" then
- colour = d[1]
- elseif position == "dbr" then
- colour = d[9]
- elseif position == "dbl" then
- colour = d[7]
- else
- print("incorrect side")
- end
- return colour
- end
- function saveColour(position, colour)
- if position == "f" then
- f[5] = colour
- elseif position == "fl" then
- f[4] = colour
- elseif position == "fr" then
- f[6] = colour
- elseif position == "fu" then
- f[2] = colour
- elseif position == "fd" then
- f[8] = colour
- elseif position == "fru" then
- f[3] = colour
- elseif position == "flu" then
- f[1] = colour
- elseif position == "fdr" then
- f[9] = colour
- elseif position == "fdl" then
- f[7] = colour
- elseif position == "r" then
- r[5] = colour
- elseif position == "rf" then
- r[4] = colour
- elseif position == "rb" then
- r[6] = colour
- elseif position == "ru" then
- r[2] = colour
- elseif position == "rd" then
- r[8] = colour
- elseif position == "rbu" then
- r[3] = colour
- elseif position == "rfu" then
- r[1] = colour
- elseif position == "rbd" then
- r[9] = colour
- elseif position == "rdf" then
- r[7] = colour
- elseif position == "b" then
- b[5] = colour
- elseif position == "br" then
- b[4] = colour
- elseif position == "bl" then
- b[6] = colour
- elseif position == "bu" then
- b[2] = colour
- elseif position == "bd" then
- b[8] = colour
- elseif position == "blu" then
- b[3] = colour
- elseif position == "bru" then
- b[1] = colour
- elseif position == "bdl" then
- b[9] = colour
- elseif position == "bdr" then
- b[7] = colour
- elseif position == "l" then
- l[5] = colour
- elseif position == "lb" then
- l[4] = colour
- elseif position == "lf" then
- l[6] = colour
- elseif position == "lu" then
- l[2] = colour
- elseif position == "ld" then
- l[8] = colour
- elseif position == "lfu" then
- l[3] = colour
- elseif position == "lbu" then
- l[1] = colour
- elseif position == "ldf" then
- l[9] = colour
- elseif position == "lbd" then
- l[7] = colour
- elseif position == "u" then
- u[5] = colour
- elseif position == "ul" then
- u[4] = colour
- elseif position == "ur" then
- u[6] = colour
- elseif position == "ub" then
- u[2] = colour
- elseif position == "uf" then
- u[8] = colour
- elseif position == "ubr" then
- u[3] = colour
- elseif position == "ubl" then
- u[1] = colour
- elseif position == "ufr" then
- u[9] = colour
- elseif position == "ufl" then
- u[7] = colour
- elseif position == "d" then
- d[5] = colour
- elseif position == "dl" then
- d[4] = colour
- elseif position == "dr" then
- d[6] = colour
- elseif position == "df" then
- d[2] = colour
- elseif position == "db" then
- d[8] = colour
- elseif position == "dfr" then
- d[3] = colour
- elseif position == "dfl" then
- d[1] = colour
- elseif position == "dbr" then
- d[9] = colour
- elseif position == "dbl" then
- d[7] = colour
- else
- print("incorrect side")
- end
- return colour
- end
- function moveF()
- oldcolourfl = getColour("fl")
- oldcolourfr = getColour("fr")
- oldcolourfu = getColour("fu")
- oldcolourfd = getColour("fd")
- oldcolourflu = getColour("flu")
- oldcolourfru = getColour("fru")
- oldcolourfdl = getColour("fdl")
- oldcolourfdr = getColour("fdr")
- oldcolourlf = getColour("lf")
- oldcolouruf = getColour("uf")
- oldcolourrf = getColour("rf")
- oldcolourdf = getColour("df")
- oldcolourlfu = getColour("lfu")
- oldcolourufl = getColour("ufl")
- oldcolourrfu = getColour("rfu")
- oldcolourufr = getColour("ufr")
- oldcolourdfl = getColour("dfl")
- oldcolourldf = getColour("ldf")
- oldcolourdfr = getColour("dfr")
- oldcolourrdf = getColour("rdf")
- newcolourfl = oldcolourfd
- newcolourfr = oldcolourfu
- newcolourfu = oldcolourfl
- newcolourfd = oldcolourfr
- newcolourflu = oldcolourfdl
- newcolourfru = oldcolourflu
- newcolourfdl = oldcolourfdr
- newcolourfdr = oldcolourfru
- newcolourlf = oldcolourdf
- newcolouruf = oldcolourlf
- newcolourrf = oldcolouruf
- newcolourdf = oldcolourrf
- newcolourlfu = oldcolourdfl
- newcolourufl = oldcolourldf
- newcolourrfu = oldcolourufl
- newcolourufr = oldcolourlfu
- newcolourdfl = oldcolourrdf
- newcolourldf = oldcolourdfr
- newcolourdfr = oldcolourrfu
- newcolourrdf = oldcolourufr
- sendSquare("fl", newcolourfl)
- sendSquare("fr", newcolourfr)
- sendSquare("fu", newcolourfu)
- sendSquare("fd", newcolourfd)
- sendSquare("flu", newcolourflu)
- sendSquare("fru", newcolourfru)
- sendSquare("fdl", newcolourfdl)
- sendSquare("fdr", newcolourfdr)
- sendSquare("lf", newcolourlf)
- sendSquare("uf", newcolouruf)
- sendSquare("rf", newcolourrf)
- sendSquare("df", newcolourdf)
- sendSquare("lfu", newcolourlfu)
- sendSquare("ufl", newcolourufl)
- sendSquare("rfu", newcolourrfu)
- sendSquare("ufr", newcolourufr)
- sendSquare("dfl", newcolourdfl)
- sendSquare("ldf", newcolourldf)
- sendSquare("dfr", newcolourdfr)
- sendSquare("rdf", newcolourrdf)
- saveCube()
- end
- function moveR()
- oldcolourrf = getColour("rf")
- oldcolourrb = getColour("rb")
- oldcolourru = getColour("ru")
- oldcolourrd = getColour("rd")
- oldcolourrfu = getColour("rfu")
- oldcolourrbu = getColour("rbu")
- oldcolourrdf = getColour("rdf")
- oldcolourrbd = getColour("rbd")
- oldcolourfr = getColour("fr")
- oldcolourur = getColour("ur")
- oldcolourbr = getColour("br")
- oldcolourdr = getColour("dr")
- oldcolourfru = getColour("fru")
- oldcolourufr = getColour("ufr")
- oldcolourbru = getColour("bru")
- oldcolourubr = getColour("ubr")
- oldcolourdfr = getColour("dfr")
- oldcolourfdr = getColour("fdr")
- oldcolourdbr = getColour("dbr")
- oldcolourbdr = getColour("bdr")
- newcolourrf = oldcolourrd
- newcolourrb = oldcolourru
- newcolourru = oldcolourrf
- newcolourrd = oldcolourrb
- newcolourrfu = oldcolourrdf
- newcolourrbu = oldcolourrfu
- newcolourrdf = oldcolourrbd
- newcolourrbd = oldcolourrbu
- newcolourfr = oldcolourdr
- newcolourur = oldcolourfr
- newcolourbr = oldcolourur
- newcolourdr = oldcolourbr
- newcolourfru = oldcolourdfr
- newcolourufr = oldcolourfdr
- newcolourbru = oldcolourufr
- newcolourubr = oldcolourfru
- newcolourdfr = oldcolourbdr
- newcolourfdr = oldcolourdbr
- newcolourdbr = oldcolourbru
- newcolourbdr = oldcolourubr
- sendSquare("rf", newcolourrf)
- sendSquare("rb", newcolourrb)
- sendSquare("ru", newcolourru)
- sendSquare("rd", newcolourrd)
- sendSquare("rfu", newcolourrfu)
- sendSquare("rbu", newcolourrbu)
- sendSquare("rdf", newcolourrdf)
- sendSquare("rbd", newcolourrbd)
- sendSquare("fr", newcolourfr)
- sendSquare("ur", newcolourur)
- sendSquare("br", newcolourbr)
- sendSquare("dr", newcolourdr)
- sendSquare("fru", newcolourfru)
- sendSquare("ufr", newcolourufr)
- sendSquare("bru", newcolourbru)
- sendSquare("ubr", newcolourubr)
- sendSquare("dfr", newcolourdfr)
- sendSquare("fdr", newcolourfdr)
- sendSquare("dbr", newcolourdbr)
- sendSquare("bdr", newcolourbdr)
- saveCube()
- end
- function moveB()
- oldcolourbr = getColour("br")
- oldcolourbl = getColour("bl")
- oldcolourbu = getColour("bu")
- oldcolourbd = getColour("bd")
- oldcolourbru = getColour("bru")
- oldcolourblu = getColour("blu")
- oldcolourbdr = getColour("bdr")
- oldcolourbdl = getColour("bdl")
- oldcolourrb = getColour("rb")
- oldcolourub = getColour("ub")
- oldcolourlb = getColour("lb")
- oldcolourdb = getColour("db")
- oldcolourrbu = getColour("rbu")
- oldcolourubr = getColour("ubr")
- oldcolourlbu = getColour("lbu")
- oldcolourubl = getColour("ubl")
- oldcolourdbr = getColour("dbr")
- oldcolourrbd = getColour("rbd")
- oldcolourdbl = getColour("dbl")
- oldcolourlbd = getColour("lbd")
- newcolourbr = oldcolourbd
- newcolourbl = oldcolourbu
- newcolourbu = oldcolourbr
- newcolourbd = oldcolourbl
- newcolourbru = oldcolourbdr
- newcolourblu = oldcolourbru
- newcolourbdr = oldcolourbdl
- newcolourbdl = oldcolourblu
- newcolourrb = oldcolourdb
- newcolourub = oldcolourrb
- newcolourlb = oldcolourub
- newcolourdb = oldcolourlb
- newcolourrbu = oldcolourdbr
- newcolourubr = oldcolourrbd
- newcolourlbu = oldcolourubr
- newcolourubl = oldcolourrbu
- newcolourdbr = oldcolourlbd
- newcolourrbd = oldcolourdbl
- newcolourdbl = oldcolourlbu
- newcolourlbd = oldcolourubl
- sendSquare("br", newcolourbr)
- sendSquare("bl", newcolourbl)
- sendSquare("bu", newcolourbu)
- sendSquare("bd", newcolourbd)
- sendSquare("bru", newcolourbru)
- sendSquare("blu", newcolourblu)
- sendSquare("bdr", newcolourbdr)
- sendSquare("bdl", newcolourbdl)
- sendSquare("rb", newcolourrb)
- sendSquare("ub", newcolourub)
- sendSquare("lb", newcolourlb)
- sendSquare("db", newcolourdb)
- sendSquare("rbu", newcolourrbu)
- sendSquare("ubr", newcolourubr)
- sendSquare("lbu", newcolourlbu)
- sendSquare("ubl", newcolourubl)
- sendSquare("dbr", newcolourdbr)
- sendSquare("rbd", newcolourrbd)
- sendSquare("dbl", newcolourdbl)
- sendSquare("lbd", newcolourlbd)
- saveCube()
- end
- function moveL()
- oldcolourlb = getColour("lb")
- oldcolourlf = getColour("lf")
- oldcolourlu = getColour("lu")
- oldcolourld = getColour("ld")
- oldcolourlbu = getColour("lbu")
- oldcolourlfu = getColour("lfu")
- oldcolourlbd = getColour("lbd")
- oldcolourldf = getColour("ldf")
- oldcolourbl = getColour("bl")
- oldcolourul = getColour("ul")
- oldcolourfl = getColour("fl")
- oldcolourdl = getColour("dl")
- oldcolourblu = getColour("blu")
- oldcolourubl = getColour("ubl")
- oldcolourflu = getColour("flu")
- oldcolourufl = getColour("ufl")
- oldcolourdbl = getColour("dbl")
- oldcolourbdl = getColour("bdl")
- oldcolourdfl = getColour("dfl")
- oldcolourfdl = getColour("fdl")
- newcolourlb = oldcolourld
- newcolourlf = oldcolourlu
- newcolourlu = oldcolourlb
- newcolourld = oldcolourlf
- newcolourlbu = oldcolourlbd
- newcolourlfu = oldcolourlbu
- newcolourlbd = oldcolourldf
- newcolourldf = oldcolourlfu
- newcolourbl = oldcolourdl
- newcolourul = oldcolourbl
- newcolourfl = oldcolourul
- newcolourdl = oldcolourfl
- newcolourblu = oldcolourdbl
- newcolourubl = oldcolourbdl
- newcolourflu = oldcolourubl
- newcolourufl = oldcolourblu
- newcolourdbl = oldcolourfdl
- newcolourbdl = oldcolourdfl
- newcolourdfl = oldcolourflu
- newcolourfdl = oldcolourufl
- sendSquare("lb", newcolourlb)
- sendSquare("lf", newcolourlf)
- sendSquare("lu", newcolourlu)
- sendSquare("ld", newcolourld)
- sendSquare("lbu", newcolourlbu)
- sendSquare("lfu", newcolourlfu)
- sendSquare("lbd", newcolourlbd)
- sendSquare("ldf", newcolourldf)
- sendSquare("bl", newcolourbl)
- sendSquare("ul", newcolourul)
- sendSquare("fl", newcolourfl)
- sendSquare("dl", newcolourdl)
- sendSquare("blu", newcolourblu)
- sendSquare("ubl", newcolourubl)
- sendSquare("flu", newcolourflu)
- sendSquare("ufl", newcolourufl)
- sendSquare("dbl", newcolourdbl)
- sendSquare("bdl", newcolourbdl)
- sendSquare("dfl", newcolourdfl)
- sendSquare("fdl", newcolourfdl)
- saveCube()
- end
- function moveU()
- oldcolourul = getColour("ul")
- oldcolourur = getColour("ur")
- oldcolourub = getColour("ub")
- oldcolouruf = getColour("uf")
- oldcolourubl = getColour("ubl")
- oldcolourubr = getColour("ubr")
- oldcolourufl = getColour("ufl")
- oldcolourufr = getColour("ufr")
- oldcolourlu = getColour("lu")
- oldcolourbu = getColour("bu")
- oldcolourru = getColour("ru")
- oldcolourfu = getColour("fu")
- oldcolourlbu = getColour("lbu")
- oldcolourblu = getColour("blu")
- oldcolourrbu = getColour("rbu")
- oldcolourbru = getColour("bru")
- oldcolourflu = getColour("flu")
- oldcolourlfu = getColour("lfu")
- oldcolourfru = getColour("fru")
- oldcolourrfu = getColour("rfu")
- newcolourul = oldcolouruf
- newcolourur = oldcolourub
- newcolourub = oldcolourul
- newcolouruf = oldcolourur
- newcolourubl = oldcolourufl
- newcolourubr = oldcolourubl
- newcolourufl = oldcolourufr
- newcolourufr = oldcolourubr
- newcolourlu = oldcolourfu
- newcolourbu = oldcolourlu
- newcolourru = oldcolourbu
- newcolourfu = oldcolourru
- newcolourlbu = oldcolourflu
- newcolourblu = oldcolourlfu
- newcolourrbu = oldcolourblu
- newcolourbru = oldcolourlbu
- newcolourflu = oldcolourrfu
- newcolourlfu = oldcolourfru
- newcolourfru = oldcolourrbu
- newcolourrfu = oldcolourbru
- sendSquare("ul", newcolourul)
- sendSquare("ur", newcolourur)
- sendSquare("ub", newcolourub)
- sendSquare("uf", newcolouruf)
- sendSquare("ubl", newcolourubl)
- sendSquare("ubr", newcolourubr)
- sendSquare("ufl", newcolourufl)
- sendSquare("ufr", newcolourufr)
- sendSquare("lu", newcolourlu)
- sendSquare("bu", newcolourbu)
- sendSquare("ru", newcolourru)
- sendSquare("fu", newcolourfu)
- sendSquare("lbu", newcolourlbu)
- sendSquare("blu", newcolourblu)
- sendSquare("rbu", newcolourrbu)
- sendSquare("bru", newcolourbru)
- sendSquare("flu", newcolourflu)
- sendSquare("lfu", newcolourlfu)
- sendSquare("fru", newcolourfru)
- sendSquare("rfu", newcolourrfu)
- saveCube()
- end
- function moveD()
- oldcolourdl = getColour("dl")
- oldcolourdr = getColour("dr")
- oldcolourdf = getColour("df")
- oldcolourdb = getColour("db")
- oldcolourdfl = getColour("dfl")
- oldcolourdfr = getColour("dfr")
- oldcolourdbl = getColour("dbl")
- oldcolourdbr = getColour("dbr")
- oldcolourld = getColour("ld")
- oldcolourfd = getColour("fd")
- oldcolourrd = getColour("rd")
- oldcolourbd = getColour("bd")
- oldcolourldf = getColour("ldf")
- oldcolourfdl = getColour("fdl")
- oldcolourrdf = getColour("rdf")
- oldcolourfdr = getColour("fdr")
- oldcolourbdl = getColour("bdl")
- oldcolourlbd = getColour("lbd")
- oldcolourbdr = getColour("bdr")
- oldcolourrbd = getColour("rbd")
- newcolourdl = oldcolourdb
- newcolourdr = oldcolourdf
- newcolourdf = oldcolourdl
- newcolourdb = oldcolourdr
- newcolourdfl = oldcolourdbl
- newcolourdfr = oldcolourdfl
- newcolourdbl = oldcolourdbr
- newcolourdbr = oldcolourdfr
- newcolourld = oldcolourbd
- newcolourfd = oldcolourld
- newcolourrd = oldcolourfd
- newcolourbd = oldcolourrd
- newcolourldf = oldcolourbdl
- newcolourfdl = oldcolourlbd
- newcolourrdf = oldcolourfdl
- newcolourfdr = oldcolourldf
- newcolourbdl = oldcolourrbd
- newcolourlbd = oldcolourbdr
- newcolourbdr = oldcolourrdf
- newcolourrbd = oldcolourfdr
- sendSquare("dl", newcolourdl)
- sendSquare("dr", newcolourdr)
- sendSquare("df", newcolourdf)
- sendSquare("db", newcolourdb)
- sendSquare("dfl", newcolourdfl)
- sendSquare("dfr", newcolourdfr)
- sendSquare("dbl", newcolourdbl)
- sendSquare("dbr", newcolourdbr)
- sendSquare("ld", newcolourld)
- sendSquare("fd", newcolourfd)
- sendSquare("rd", newcolourrd)
- sendSquare("bd", newcolourbd)
- sendSquare("ldf", newcolourldf)
- sendSquare("fdl", newcolourfdl)
- sendSquare("rdf", newcolourrdf)
- sendSquare("fdr", newcolourfdr)
- sendSquare("bdl", newcolourbdl)
- sendSquare("lbd", newcolourlbd)
- sendSquare("bdr", newcolourbdr)
- sendSquare("rbd", newcolourrbd)
- saveCube()
- end
- function randomise()
- local randommoves = math.random(10,20)
- nomove = true
- for i=1, randommoves do
- local move = math.random(1,12)
- if move == 1 then
- moveF()
- elseif move == 2 then
- moveR()
- elseif move == 3 then
- moveB()
- elseif move == 4 then
- moveL()
- elseif move == 5 then
- moveU()
- elseif move == 6 then
- moveD()
- elseif move == 7 then
- moveF()
- moveF()
- moveF()
- elseif move == 8 then
- moveR()
- moveR()
- moveR()
- elseif move == 9 then
- moveB()
- moveB()
- moveB()
- elseif move == 10 then
- moveL()
- moveL()
- moveL()
- elseif move == 11 then
- moveU()
- moveU()
- moveU()
- elseif move == 12 then
- moveD()
- moveD()
- moveD()
- end
- end
- nomove = false
- refresh()
- end
- function refresh()
- for i = 0, 35 do
- local init = (math.floor(i/4))+1
- if init == 1 then
- a = 5
- elseif init == 2 then
- a = 4
- elseif init == 3 then
- a = 6
- elseif init == 4 then
- a = 2
- elseif init == 5 then
- a = 8
- elseif init == 6 then
- a = 3
- elseif init == 7 then
- a = 1
- elseif init == 8 then
- a = 9
- elseif init == 9 then
- a = 7
- end
- send(i, f[a])
- end
- for i = 36, 71 do
- local init = (math.floor((i-36)/4))+1
- if init == 1 then
- a = 5
- elseif init == 2 then
- a = 4
- elseif init == 3 then
- a = 6
- elseif init == 4 then
- a = 2
- elseif init == 5 then
- a = 8
- elseif init == 6 then
- a = 3
- elseif init == 7 then
- a = 1
- elseif init == 8 then
- a = 9
- elseif init == 9 then
- a = 7
- end
- send(i, r[a])
- end
- for i = 72, 107 do
- local init = (math.floor((i-72)/4))+1
- if init == 1 then
- a = 5
- elseif init == 2 then
- a = 4
- elseif init == 3 then
- a = 6
- elseif init == 4 then
- a = 2
- elseif init == 5 then
- a = 8
- elseif init == 6 then
- a = 3
- elseif init == 7 then
- a = 1
- elseif init == 8 then
- a = 9
- elseif init == 9 then
- a = 7
- end
- send(i, b[a])
- end
- for i = 108, 143 do
- local init = (math.floor((i-108)/4))+1
- if init == 1 then
- a = 5
- elseif init == 2 then
- a = 4
- elseif init == 3 then
- a = 6
- elseif init == 4 then
- a = 2
- elseif init == 5 then
- a = 8
- elseif init == 6 then
- a = 3
- elseif init == 7 then
- a = 1
- elseif init == 8 then
- a = 9
- elseif init == 9 then
- a = 7
- end
- send(i, l[a])
- end
- for i = 144, 179 do
- local init = (math.floor((i-144)/4))+1
- if init == 1 then
- a = 5
- elseif init == 2 then
- a = 4
- elseif init == 3 then
- a = 6
- elseif init == 4 then
- a = 2
- elseif init == 5 then
- a = 8
- elseif init == 6 then
- a = 3
- elseif init == 7 then
- a = 1
- elseif init == 8 then
- a = 9
- elseif init == 9 then
- a = 7
- end
- send(i, u[a])
- end
- for i = 180, 215 do
- local init = (math.floor((i-180)/4))+1
- if init == 1 then
- a = 5
- elseif init == 2 then
- a = 4
- elseif init == 3 then
- a = 6
- elseif init == 4 then
- a = 2
- elseif init == 5 then
- a = 8
- elseif init == 6 then
- a = 3
- elseif init == 7 then
- a = 1
- elseif init == 8 then
- a = 9
- elseif init == 9 then
- a = 7
- end
- send(i, d[a])
- end
- send(220, l[6])
- end
- setup()
- readInput()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement