Add mod security

This preserves compatibility with most mods.

Things that you can't do anymore:
  * Access any files not in the mod, world, user, or share path.
  * Run Lua bytecode.
  * Use `require()` or anything in the `package` library (`require()` and some `package` functions can load C modules, the rest are only useNote:
This isn't quite ready yet, you can still load bytecode if `init.lua` is a bytecode file.  ful if you have access to the other functions).
  * Use `os.execute()` or `io.popen()` to run shell commands.
  * Use the registry or get/set user values with the debug library (user values are a Lua 5.2 feature anyway).

You can do just about anything else, including using `getfenv` / `setfenv` and `getmetatable` / `setmetatable` (these functions are only dangerous if the sandbox is created from Lua).

I'd appreciate any comments on other possible security holes.

std::getc() returns an int. Doing an implicit cast like this is not nice and you introduced a bug if EOF is returned (it is cast to char which -- if char is unsigned [implementation defined] -- and therefore your td::getc(fp)) != EOF may not ever be true, depending on the OS and/or the C++ compiler used)