Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local indexes = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f"}
- local palette = {}
- local monitor = peripheral.wrap("right")
- local w, h = monitor.getSize()
- local buffer = window.create(monitor, 1, 1, w, h, true)
- function makePalette()
- local colorNum = 1
- local monitor = peripheral.wrap("right")
- for colorName, colorId in pairs(colors) do
- if type(colorId)=="number" then
- buffer.setPaletteColor(colors[colorName], colorNum/16, colorNum/16, colorNum/16)
- --buffer.setPaletteColor(colors[colorName], 0, 0, 0)
- palette[indexes[colorNum]] = colorId
- print(indexes[colorNum].." is now "..colorName.." with color "..colorNum*20)
- colorNum = colorNum+1
- end
- end
- end
- function drawImage(file, width, height)
- buffer.setVisible(false)
- for x = 1, width do
- for y = 1, height do
- paintutils.drawPixel(x, y, palette[file.read()])
- end
- end
- buffer.setVisible(true)
- end
- function playMovie(path)
- local file = fs.open(path, "r")
- local dimensions = ""
- local width, height
- while true do
- local char = file.read()
- dimensions = dimensions..char
- if char == ":" then break end
- end
- width = tonumber(dimensions:match("%d*[%x]"))
- height = tonumber(dimensions:match("([%x]%d*)[%:]"))
- term.native().write(width.." "..height)
- while true do
- drawImage(file, width, height)
- sleep(0.1)
- end
- end
- term.redirect(buffer)
- monitor.setTextScale(0.5)
- makePalette()
- playMovie("movie")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement