Heads up on a nice feature of lua:
Assignments can be done simultaneously, obviating the need for a swap function. So, for instance, you could simplify your sorty() function:
function sorty(t) nt=t if (t > t) then t,t=t,t end if (t > t) then t,t=t,t end if (t > t) then t,t=t,t end return nt end
Mind you, the benefits of this kind of intrinsic swapping are felt better when using variables directly, rather than accessing table members, as it introduces a couple of extra table dereferences that would normally be consolidated inside a single swap() function. So, in this case, you only about break even on tokens, but the performance would be a little better without the temporary and the call overhead.
Nice demo btw. I might steal your icosahedron setup code, which is always a bother to re-derive when I need one, and I haven't bothered to do it since I started messing with PICO-8. ;)
[Please log in to post a comment]