Hi, I would have a suggestion about Object API in lua CoreLibs.
for small project, it's OK to put all class in globals, but it's not Pleasant in Developer Experience, a symbol defined by string is put in global namespace magicaly. IDE is confuse and do not know the class symbol.
I dig a bit in CoreLibs object API, and see an undocumented namespaces parameter, basicly a lua table, store it where you want. (I choose to use a namespaces.lua file declaring a global variable namespaces storing all my namespaces, and declaring class slots in the namespaces for IDE)
So my use of object api is
class('Ball', {}, namespaces.fall_in_hole).extends(gfx.sprite)
local Ball <const> = namespaces.fall_in_hole.Ball
It could be great to online this like that :
local Ball <const> = class('Ball', {}, namespaces.fall_in_hole).extends(gfx.sprite)
For that, Only need a small update in CoreLibs object.lua, add one line in extends method so it return the class.
I created my own helper global function to do this, but it'd be nice to not need to
function NewClass(name, parent)
class(name).extends(parent)
return _G[name]
end
local S = NewClass("MySprite", playdate.graphcis.sprite)
function S:init() end
You can actually make this change yourself, in your local copy of the library. It's in PlaydateSDK/CoreLibs/object.lua. (Note that you'll have to redo any changes to these files after updating the SDK.) But hopefully we can add this soon.