Lua: massive fixing

Fixed all Lua implementations; found out 8 and 12 aren't working as they
should anymore. The rest are working properly and look good as well
:stuck_out_tongue_winking_eye:
Also added a template for future solutions.
Oh yeah, and I've moved a lot of functions to the library.