Lua/Love2D Resource Loader (Queue)
In Lua, it's not necessary to separate statements by a semicolon (it's not even necessary to do it when writting several statements in the same line). However it's possible to do it.

In this snippet:


for k, v in pairs(self.res.queue) do
    if (not v or not v.f or not v.t) then goto continue end;
    if (v.t ~= self.RESOURCE_FONT) then
        queueChannel:push(v);
    else
        fonts[k] = v;
    end
    ::continue::
end



You're using pairs in several parts of the code to iterate tables which are actually arrays. Variable self.res.queue is an array since:


function GameState:queue(file, arg)
    self.res.loaded = self.res.loaded + 1;
    self.res.queue[self.res.loaded] = &lt;object&gt;;
end



In the cases a table is actually an array is preferred to use ipairs because is way more faster than pairs. In addition to that, it tells other people reading the code the table is actually an array (which is a valuable hint in a dynamic language such as Lua).

At the bottom of GameState:loadQueue:


if (table.size(self.res.queue)-table.size(fonts) &gt; 0) then
    queueThread:start(); else
    queueChannel = nil;
    queueThread = nil;
    return;
end

self.state = self.STATE_LOADING



The return statement in the else branch can be removed if you move self.state up to the then branch. The semantics hold as either queueThread:start() or not.

if (table.size(self.res.queue)-table.size(fonts) &gt; 0) then
    self.state = self.STATE_LOADING;
    queueThread:start();
else
    queueChannel = nil;
    queueThread = nil;
    return;
end