Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- colors.white 1 0x1 0000000000000001
- colors.orange 2 0x2 0000000000000010
- colors.magenta 4 0x4 0000000000000100
- colors.lightBlue 8 0x8 0000000000001000
- colors.yellow 16 0x10 0000000000010000
- colors.lime 32 0x20 0000000000100000
- colors.pink 64 0x40 0000000001000000
- colors.gray 128 0x80 0000000010000000
- colors.lightGray 256 0x100 0000000100000000
- colors.cyan 512 0x200 0000001000000000
- colors.purple 1024 0x400 0000010000000000
- colors.blue 2048 0x800 0000100000000000
- colors.brown 4096 0x1000 0001000000000000
- colors.green 8192 0x2000 0010000000000000
- colors.red 16384 0x4000 0100000000000000
- colors.black
- local Args = ...
- local file = fs.open(Args, "r") or fs.open(Args..".rec", "r") or error("Cannot open the file "..Args", 0)
- local version = file.readLine()
- if version ~= "1.0" then
- term.clear()
- term.setTextColor(colors.red)
- term.setCursorPos(10, 5)
- print("[!] Warning : file version doesn't match editor version !\nTrying to do the job but if it doesn't work please check for update")
- term.setTextColor(colors.white)
- end
- local movie = textutils.unserialize(file.readLine())
- file.close()
- local currentFrame = 1
- local termX, termY = term.getSize()
- local exit = false
- local currentColor = colors.white
- local function drawFrame(number)
- local frame = movie[number]
- for _, pixel in ipairs(frame) do
- term.setCursorPos(pixel.x, pixel.y)
- term.setTextColor(pixel.t)
- term.setBackgroundColor(pixel.b)
- term.write(pixel.c)
- end
- end
- local function moveToFrame(number)
- currentFrame = number
- drawFrame(number)
- drawHUD()
- end
- local function drawHUD()
- paintutils.drawPixel(termX, 1, colors.lightBlue)
- paintutils.drawPixel(termX, 2, colors.blue)
- paintutils.drawPixel(termX, 3, colors.cyan)
- paintutils.drawPixel(termX-1, 1, colors.red)
- paintutils.drawPixel(termX-1, 2, colors.orange)
- paintutils.drawPixel(termX-1, 3, colors.purple)
- paintutils.drawPixel(termX-1, 4, colors.magenta)
- paintutils.drawPixel(termX-1, 5, colors.lime)
- paintutils.drawPixel(termX-1, 6, colors.green)
- paintutils.drawPixel(termX-1, 7, colors.pink)
- paintutils.drawPixel(termX, 4, colors.yellow)
- paintutils.drawPixel(termX, 5, colors.brown)
- paintutils.drawPixel(termX, 6, colors.white)
- paintutils.drawPixel(termX, 7, colors.black)
- paintutils.drawPixel(termX, 8, colors.lightGray)
- paintutils.drawPixel(termX-1, 8, colors.gray)
- term.setCursorPos(termX-4, termY)
- term.setColorBackground(colors.lightBlue)
- term.setTextColor(colors.blue)
- write("SAVE")
- term.setCursorPos(termX-9, termY)
- write(currentFrame)
- term.setColorBackground(colors.black)
- term.setTextColor(colors.white)
- end
- local function saveMovie()
- local sMovie = textutils.serialize(movie)
- local file = fs.open(path, "w")
- file.write(version)
- file.write(sMovie)
- file.close()
- print("Successfully saved file")
- end
- local function copyFrame(toCopy, number)
- for i = 1, number do
- end
- d
- while exit ~= true do
- drawFrame(currentFrame)
- drawHUD()
- local event, param, param1, param2 = os.pullEvent()
- if event == "key" then
- if param == keys.left then
- if currentFrame ~= 1 then
- currentFrame = currentFrame - 1
- else
- currentFrame = #movie --put to the last frame
- end
- elseif param == keys.right then
- if currentFrame ~= #movie then
- currentFrame = currentFrame + 1
- else
- currentFrame = 1 --put to the last frame
- end
- elseif param == keys.c then
- paintutils.drawLine(15, 7, 18, 7, colors.lightGray)
- term.setCursorPos(1, 7)
- write("Number of copy :")
- local copyNumber = tonumber(read())
- copyFrame(currentFrame, copyNumber)
- elseif param == keys.q then
- break
- end
- elseif event == "mouse_click" then
- local x, y = param1, param2
- if x = termX and y = 1 then
- currentColor = colors.lightBlue
- elseif x = termX and y = 2 then
- currentColor = colors.blue
- elseif x = termX and y = 3 then
- currentColor = colors.cyan
- elseif x = termX and y = 4 then
- currentColor = colors.yellow
- elseif x = termX and y = 5 then
- currentColor = colors.brown
- elseif x = termX and y = 6 then
- currentColor = colors.white
- elseif x = termX and y = 7 then
- currentColor = colors.black
- elseif x = termX and y = 8 then
- currentColor = colors.lightGray
- elseif x = termX-1 and y = 1 then
- currentColor = colors.red
- elseif x = termX-1 and y = 2 then
- currentColor = colors.orange
- elseif x = termX-1 and y = 3 then
- currentColor = colors.purple
- elseif x = termX-1 and y = 4 then
- currentColor = colors.magenta
- elseif x = termX-1 and y = 5 then
- currentColor = colors.lime
- elseif x = termX-1 and y = 6 then
- currentColor = colors.green
- elseif x = termX-1 and y = 7 then
- currentColor = colors.pink
- elseif x = termX-1 and y = 8 then
- currentColor = colors.gray
- elseif x >= termX-4 and y = termY then
- saveMovie()
- elseif x >= termX-9 and x <= termX-5 and y = termY then
- paintutils.drawLine(11, 7, 15, 7, colors.lightGray)
- term.setCursorPos(1, 7)
- write("Frame n° :")
- currentFrame = tonumber(read())
- end
Add Comment
Please, Sign In to add comment