Search found 193 matches

by MrFariator
Sat Jan 16, 2021 11:53 am
Forum: Libraries and Tools
Topic: SUPER STRICT for LUA
Replies: 27
Views: 2498

Re: SUPER STRICT for LUA

Cheers for the another quick fix. I've managed to have sstrict encompass several thousand lines of code pretty neatly, the only minor problem I noticed was that sometimes when you have unused or redefined variables, the error would be raised incorrectly for the next line. Ex: local myVar, myUnusedVa...
by MrFariator
Sat Jan 16, 2021 9:04 am
Forum: Libraries and Tools
Topic: SUPER STRICT for LUA
Replies: 27
Views: 2498

Re: SUPER STRICT for LUA

Ah, I must have missed the --!strict command as I was glancing through the thread and plopping sstrict into my code. Using that in tandem with the updated version with the couple fixes seems to be running mostly fine for now, as far as I can see in my testing. However, I did run in to this one issue...
by MrFariator
Fri Jan 15, 2021 10:43 pm
Forum: Libraries and Tools
Topic: SUPER STRICT for LUA
Replies: 27
Views: 2498

Re: SUPER STRICT for LUA

I have cases where I let certain functions (debug stuff, mainly) be replaced by empty functions in "release" builds, effectively turning those into NoOPs, so sstrict threw a bunch of hissyfits about that. Another issue I ran into was the following function (from bump.lua): function World:hasItem(ite...
by MrFariator
Thu Jan 14, 2021 4:15 pm
Forum: Support and Development
Topic: Master tables
Replies: 6
Views: 314

Re: Master tables

Can this approach work in larger projects? Sure, I don't see why not. Of course, be mindful of the potential performance penalties that might occur due to the extra added hoops for simple table lookups. Here it's neglible, but with more complex __index chaining it could get costly in performance cri...
by MrFariator
Wed Jan 13, 2021 5:36 pm
Forum: Support and Development
Topic: Master tables
Replies: 6
Views: 314

Re: Master tables

Oh, oops, yes, that is a mistake that is also present in the original code. Somehow slipped past me; it obviously should be put inside the metatable within the setmetatable call. I am going to assume OP first wanted to get the __index working, and had this __call line in there doing nothing.
by MrFariator
Wed Jan 13, 2021 5:22 pm
Forum: Support and Development
Topic: Master tables
Replies: 6
Views: 314

Re: Master tables

There's two ways to implementing the __index metamethod. Lets cover the function approach first: When you try to fetch a value from a table by key that does not exist, and the table's metatable has __index defined and it is a function, this allows you to basically "redirect" the search, or create ot...
by MrFariator
Mon Jan 11, 2021 9:00 pm
Forum: Support and Development
Topic: Help Generating Enemies from Enemy Class
Replies: 3
Views: 835

Re: Help Generating Enemies from Enemy Class

You could put the table.insert line to love.load in main.lua to spawn an enemy as the game starts, to your love.update when certain conditions are met (like the timer example I provided), or somewhere else. It's up to you, really. In general terms, you basically manage a collection of enemies (the l...
by MrFariator
Mon Jan 11, 2021 2:12 am
Forum: Support and Development
Topic: Help Generating Enemies from Enemy Class
Replies: 3
Views: 835

Re: Help Generating Enemies from Enemy Class

You'll need to define a table similar to the one that contains bullets. function love.load() listOfEnemies = {} -- ...rest end Any time you want to spawn an enemy (when and where being up to you), you simply call the constructor function, and add the resulting object to the end of that table. table....
by MrFariator
Sat Jan 09, 2021 11:36 pm
Forum: Support and Development
Topic: Do memory pools actually work in love2D
Replies: 10
Views: 1664

Re: Do memory pools actually work in love2D

Pooling can help, and I've successfully used it to reduce memory footprint in my projects, but it won't magically fix your memory issues if your objects generate a whole bunch of garbage (temporary tables, closures, etc). That garbage will pile up over time, until the garbage collector will run its ...
by MrFariator
Sat Jan 02, 2021 2:32 pm
Forum: General
Topic: Optimization Stuff
Replies: 40
Views: 15989

Re: Optimization Stuff

Perhaps it's splitting hairs, but I wouldn't consider lua to be slow by design, but rather by its implementation. You could write a C compiler that outputs very inefficient stuff, or even just gauge the difference between vanilla (5.1) lua and luajit.