Improve the LuaController

Changes:
  * Stops code after a certain number of instructions.
  * Allows functions, due to instruction counting.
  * Allows loops and goto with non-JIT Lua (LuaJIT doesn't count looping as an instruction, allowing infinite loops), due to instruction counting.
  * Adds some safe functions.
  * Limits the amount of printing that can be done (to prevent console flooding, currently limits to a max of slightly under 1/sec continuously, although bursts of up to eight are allowed).
  * Code cleanup.
  * More...

**Note: May be buggy, needs testing.**