natiny_script_open_std
void natiny_script_open_std(NatinyScript script);
Opens Lua's own standard library into the script - all of it - and points
require() at the mounted folders.
Parameters
| Name | Type | Description |
|---|---|---|
script |
NatinyScript |
The state to open the library into |
Example
NatinyScript script = natiny_script_create();
natiny_script_open_std(script);
natiny_script_open_all(script);
What the script gets
The complete standard library: string, table, math, utf8,
coroutine, package, and io, os and debug with them. This is the set a
program the player wrote gets, on the understanding that it is their program
running on their machine.
It also does two things the plain library does not:
require()reads through the resource stack. Arequire("game.state")becomesgame/state.lualooked up withnatiny_resource_load, so it is the same name whether that is a loose file, an entry in a pack, or the same name in a mod mounted over the top. Lua's own searchers are left in place and run first, so a file lying where Lua can open it is still found the way it was.require("natiny")returns the module table. Not a global: the script sayslocal natiny = require("natiny")and nothing appears under a name it did not ask for.