CoreModules enum.
CoreModules Enum
TheCoreModules enum allows fine-grained control over which standard library modules are loaded into your script environment. This is particularly useful for sandboxing and security.
Basic Modules
| Module | Description | Flag |
|---|---|---|
| Basic | Core functions like print, type, tostring, assert | CoreModules.Basic |
| GlobalConsts | Global constants: _G, _VERSION, _SOLARSHARP | CoreModules.GlobalConsts |
| TableIterators | Iterator functions: next, ipairs, pairs | CoreModules.TableIterators |
| Metatables | Metatable operations: setmetatable, getmetatable, rawset, rawget, rawequal, rawlen | CoreModules.Metatables |
| ErrorHandling | Error handling: pcall, xpcall | CoreModules.ErrorHandling |
Package Modules
| Module | Description | Flag |
|---|---|---|
| String | String manipulation functions | CoreModules.String |
| Table | Table manipulation functions | CoreModules.Table |
| Math | Mathematical functions and constants | CoreModules.Math |
| Coroutine | Coroutine creation and management | CoreModules.Coroutine |
| Bit32 | Bitwise operations | CoreModules.Bit32 |
| IO | File I/O operations | CoreModules.IO |
| OS_Time | Time and date functions | CoreModules.OS_Time |
| OS_System | System operations (not available in Unity) | CoreModules.OS_System |
| Debug | Debugging utilities (limited support) | CoreModules.Debug |
| Json | JSON parsing and serialization (SolarSharp extension) | CoreModules.Json |
LoadMethods
| Flag | Description |
|---|---|
| LoadMethods | Dynamic loading: load, loadsafe, loadfile, loadfilesafe, dofile, require |
Presets
SolarSharp provides convenient presets for common use cases:Preset_HardSandbox
Preset_SoftSandbox
Preset_Default
Preset_Complete
Usage Example
Important Notes
UTF-16 vs UTF-8
SolarSharp runs on .NET, which uses UTF-16 for strings internally. This differs from standard Lua’s UTF-8 encoding:- String length is measured in UTF-16 code units, not bytes
- The
string.byte()function returns UTF-16 code unit values - Pattern matching operates on UTF-16 characters
Platform Limitations
- IO and OS_System modules are not supported under Unity
- Some debug functionality is platform-dependent
- File operations require appropriate platform access configuration