I've been learning Pico-8 and Lua a little and I'm wondering: is Lua object oriented at all? It would be really useful to know whether there is some way of making classes and objects, or is it all just functions?
Lua has prototypical inheritance, but the pico-8 doesn't provide access to setmetatable, so things are restricted to x:y(...) self calls. it's syntactically identical to typing "x.y(x,...)"
I am not even sure what "x.y(x,...)" is or what it would do. y is a function in x, and it has unlimited parameters? Anyway, sorry, that is not even my main concern - I am sure I will get to learning that eventually. But assuming I knew what it was, would I be able to use that and similar features to get object oriented features? If not, how to most Pico-8 users handle lots of identical objects, e.g., the many walls and characters and such that can be placed in the level editor. Thanks!
Multiple objects of a similar type are created by simply copying all the respective properties into a new table. There is no way to 'clone' an existing object.
Things like level data is better suited by creating an enumeration list that point to a property table. ie: world = { GRASS, GRASS, GRASS, WALL } etc. Obviously the tile map is better suited for this kind of data, but it's how things that don't really fit into the pico-8 paradigm would work best.
Thanks a lot! I suppose that means you can store a tables inside a table, or tables inside lists, or something similar? If not I suppose you could use a multidimensional table.
One more question: Where exactly is the tile map data stored? I can't find anything on it. I'm sure I could find it in a demo cartridge but any explanation on that would be really helpful.
[Please log in to post a comment]