i was using testing the classic library and notice nobody made a version for pico8 ,
the main motive probally is because pico8 uses tokens to limit your scope ,so something like oop can be really token intesive but, i made it anyways so here is classic in pico8.
--classic but in pico8 --class class={} class.__index=class function class:ext() local nclass={} for k,v in pairs(self) do if sub(k,1,1)=="_" and sub(k,2,2)=="_" then nclass[k]=v end end nclass.super=self nclass.__index=nclass setmetatable(nclass,self) return nclass end function class:new() end function class:__call(...) local obj=setmetatable({},self) obj:new(...) return obj end |
tip:use with responsibility.



fun! but tokens could be saved (for example condense class.__call__
into one line), and instead of copying all methods into each object, prototype inheritance could be used!
[Please log in to post a comment]