Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions playdate/imagetable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ local module = {}
playdate.graphics.imagetable = module

local meta = {}
meta.__index = meta
module.__index = meta

-- TODO: overload the `[]` array index operator to return an image
-- TODO: overload the `#` length operator to return the number of images
meta.__index = function(table, key)
if type(key) == "number" then
return table:getImage(key)
else
return rawget(meta, key)
end
end

meta.__len = function(table)
return table.length
end

module.__index = meta

-- TODO: handle overloaded signature (count, cellsWide, cellSize)
function module.new(path, cellsWide, cellsSize)
Expand Down