The screen
library provides a way of easily capturing screenshots.
-- Create a new buffer
local screen = require("screen");
Capture the entire screen area.
res = screen.capture();
local x = res.x;
local y = res.y;
local w = res.w;
local h = res.h;
local image = res.image;
Capture the specified screen area.
res = screen.capture(0, 0, 400, 400);
local x = res.x;
local y = res.y;
local w = res.w;
local h = res.h;
local image = res.image;
Optionally it can return only the sub-area that has changed since the previous call. If no pixels have changed since the previous call then the image will be nil
. The returned coordinates and size will correspond to the sub-area that has actually changed.
res = screen.capture(0, 0, 400, 400, true);
if (res.image) then
print("area changed");
else
print("area same");
end
Get the screen size.
w,h = screen.size();