forked from hkc/cc-stuff
42 lines
840 B
Lua
42 lines
840 B
Lua
local ccpi = require("ccpi")
|
|
local args = { ... }
|
|
|
|
local terminal = term.current()
|
|
if args[1] == "-m" then
|
|
table.remove(args, 1)
|
|
print("Using monitor: " .. args[1])
|
|
terminal = peripheral.wrap(table.remove(args, 1))
|
|
end
|
|
|
|
local frames = {}
|
|
local n_frames = tonumber(args[1])
|
|
local base_path = args[2]
|
|
|
|
for i = 1, n_frames do
|
|
local url = string.format(base_path, i)
|
|
print("GET " .. url)
|
|
local req, err = http.get(url, nil, true)
|
|
if not req then
|
|
printError(err)
|
|
return
|
|
end
|
|
local img, err = ccpi.parse(req)
|
|
if not img then
|
|
printError(err)
|
|
return
|
|
else
|
|
print(img.w .. "x" .. img.h)
|
|
end
|
|
table.insert(frames, img)
|
|
req.close()
|
|
end
|
|
|
|
local frame_no = 0
|
|
while true do
|
|
local frame = frames[(frame_no % #frames) + 1]
|
|
ccpi.draw(frame, 1, 1, terminal)
|
|
os.sleep(0.0)
|
|
frame_no = frame_no + 1
|
|
end
|
|
|