Log In  

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?

P#18568 2016-01-31 23:23 ( Edited 2016-02-04 03:31)

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,...)"

P#18569 2016-01-31 23:36 ( Edited 2016-02-01 04:36)

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!

P#18587 2016-02-01 17:53 ( Edited 2016-02-01 22:53)

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.

P#18592 2016-02-01 23:42 ( Edited 2016-02-02 04:43)

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.

P#18637 2016-02-03 22:31 ( Edited 2016-02-04 03:31)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-09-19 14:51 | 0.010s | 4194k | Q:17