Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tCube = {}
- rednet.open('back')
- local tCoords = {
- {{12, 13, 14}, {7, 8, 9}},
- {{15, 16, 17}, {7, 8, 9}},
- {{14, 13, 12}, {6, 5, 4}},
- {{9, 10, 11}, {7, 8, 9}},
- {{12, 13, 14}, {10, 11, 12}},
- {{12, 13, 14}, {13, 14, 15}},
- ['buttons'] = {
- {12, 3, '04'}, {13, 2, '05'}, {14, 3, '06'}, -- up
- {12, 16, '14'}, {13, 17, '15'}, {14, 16, '16'}, -- down
- {8, 7, '17'}, {7, 8, '18'}, {8, 9, '19'}, -- left
- {18, 7, '07'}, {19, 8, '08'}, {18, 9, '09'}, -- right
- {11, 10, '01'}, {10, 11, '02'}, {11, 12, '03'}, -- cw
- {15, 10, '11'}, {16, 11, '12'}, {15, 12, '13'}, -- ccw
- {2, 16, 'reset'}, {18, 16, 'shuffle'} -- reset, shuffle
- }}
- local function drawButtons()
- for b = 1, #tCoords['buttons'] do
- paintutils.drawPixel(tCoords['buttons'][b][1], tCoords['buttons'][b][2], 0x100)
- end
- term.setBackgroundColor(0x8000)
- term.setCursorPos(tCoords['buttons'][19][1]+1, tCoords['buttons'][19][2])
- write('RESET')
- term.setCursorPos(tCoords['buttons'][20][1]+1, tCoords['buttons'][20][2])
- write('SHUFFLE')
- end
- local function drawNet()
- for side = 1, 6 do
- for cell = 1, 9 do
- if cell == 1 then x, y = 1, 1
- elseif cell == 2 then x, y = 2, 1
- elseif cell == 3 then x, y = 3, 1
- elseif cell == 4 then x, y = 1, 2
- elseif cell == 5 then x, y = 2, 2
- elseif cell == 6 then x, y = 3, 2
- elseif cell == 7 then x, y = 1, 3
- elseif cell == 8 then x, y = 2, 3
- elseif cell == 9 then x, y = 3, 3
- end
- s = ('s'..side)
- color = tCube[s][cell]
- if color == 14 then color = 0x4000
- elseif color == 0 then color = 0x1
- elseif color == 13 then color = 0x2000
- elseif color == 4 then color = 0x10
- elseif color == 11 then color = 0x800
- elseif color == 1 then color = 0x2
- end
- paintutils.drawPixel(tCoords[side][1][x], tCoords[side][2][y], color)
- end
- end
- end
- while true do
- term.setBackgroundColor(0x8000)
- term.clear()
- term.setCursorPos(1, 1)
- local id, msg = rednet.receive('cube_0')
- tCube = textutils.unserialize(msg)
- tCube['s2'][1], tCube['s2'][3], tCube['s2'][9], tCube['s2'][7] =
- tCube['s2'][3], tCube['s2'][9], tCube['s2'][7], tCube['s2'][1]
- tCube['s2'][2], tCube['s2'][6], tCube['s2'][8], tCube['s2'][4] =
- tCube['s2'][6], tCube['s2'][8], tCube['s2'][4], tCube['s2'][2]
- tCube['s4'][1], tCube['s4'][7], tCube['s4'][9], tCube['s4'][3] =
- tCube['s4'][7], tCube['s4'][9], tCube['s4'][3], tCube['s4'][1]
- tCube['s4'][2], tCube['s4'][4], tCube['s4'][8], tCube['s4'][6] =
- tCube['s4'][4], tCube['s4'][8], tCube['s4'][6], tCube['s4'][2]
- drawButtons()
- drawNet()
- local et, bn, x, y = os.pullEvent("mouse_click")
- for i = 1, #tCoords['buttons'] do
- if x == tCoords['buttons'][i][1] and y == tCoords['buttons'][i][2] then
- rednet.broadcast(tCoords['buttons'][i][3], 'cube_0')
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement