Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- width = 0
- height = 0
- args = {...}
- file = args[1]
- w,h = term.getSize()
- f = fs.open(file,"r")
- --data = f.readAll()
- f.close()
- fi = fs.open(file,"r")
- lines = 0
- line = fi.readLine()
- width = #line
- while line do
- line = fi.readLine()
- lines = lines + 1
- end
- fi.close()
- height = lines
- --print(width)
- --print(height)
- mx = 0
- my = 0
- image = {}
- color = {
- ["0"] = 1,
- ["1"] = 2,
- ["2"] = 4,
- ["3"] = 8,
- ["4"] = 16,
- ["5"] = 32,
- ["6"] = 64,
- ["7"] = 128,
- ["8"] = 256,
- ["9"] = 512,
- ["a"] = 1024,
- ["b"] = 2048,
- ["c"] = 4096,
- ["d"] = 8192,
- ["e"] = 16384,
- ["f"] = 32768,
- [" "] = 32768
- }
- print(width)
- print(height)
- sleep(1)
- fil = fs.open(file,"r")
- for y = 1,height do
- line = fil.readLine()
- image[y] = {}
- os.queueEvent("randomEvent")
- os.pullEvent()
- print("did event "..y)
- for x = 1,width do
- --os.queueEvent("randomEvent")
- --os.pullEvent()
- if line then
- line = line..""
- image[y][x] = color[line:sub(x,x)]
- else
- print("uh oh no value at x: "..x.." y: "..y)
- end
- end
- end
- fil.close()
- function display()--xx,yy)
- for xc = 1,w do
- for yc = 1,h do
- if xc <= width and yc <= height then
- --print(image[xc+mx][yc+my])
- num = image[yc+my][xc+mx]
- --write(num)
- if num then term.setBackgroundColor(image[yc+my][xc+mx]) else term.setBackgroundColor(colors.black) end--[yc+my]) end
- term.setCursorPos(xc,yc)
- write(" ")
- end
- end
- end
- end
- term.clear()
- display(0,0)
- run = true
- function go()
- term.setBackgroundColor(colors.black)
- term.clear()
- display(mx,my)
- end
- while run do
- event,key = os.pullEvent("key")
- if key == 200 and my >= 20 then
- my = my - 20
- go()
- elseif key == 208 and my <= height - h - 20 then
- my = my + 20
- go()
- elseif key == 203 and mx >= 20 then
- mx = mx - 20
- go()
- elseif key == 205 and mx <= width - w - 20 then
- mx = mx + 20
- go()
- elseif key == 28 then
- run = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment