diff --git a/src/Lua.cs b/src/Lua.cs
index ef75c3a..61cfcc7 100644
--- a/src/Lua.cs
+++ b/src/Lua.cs
@@ -906,9 +906,8 @@ public void PushString(string value, params object[] args)
/// Pushes a double with value n onto the stack.
///
///
- public void PushNumber(double number) => NativeMethods.lua_pushnumber(_luaState, number);
-
-
+ public void PushNumber(double number) => NativeMethods.lua_pushnumber(_luaState, number);
+
///
/// Pushes the thread represented by L onto the stack. Returns true if this thread is the main thread of its state.
///
@@ -2005,14 +2004,156 @@ public bool NewMetaTable(string name)
return NativeMethods.luaL_newmetatable(_luaState, name) != 0;
}
+ private static int OpenBase(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_base(luaState);
+ }
+
+ private static int OpenPackage(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_package(luaState);
+ }
+
+ private static int OpenCoroutine(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_coroutine(luaState);
+ }
+
+ private static int OpenTable(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_table(luaState);
+ }
+
+ private static int OpenIO(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_io(luaState);
+ }
+
+ private static int OpenOS(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_os(luaState);
+ }
+
+ private static int OpenString(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_string(luaState);
+ }
+
+ private static int OpenUTF8(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_utf8(luaState);
+ }
+
+ private static int OpenMath(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_math(luaState);
+ }
+
+ private static int OpenDebug(IntPtr luaState)
+ {
+ return KeraLua.NativeMethods.luaopen_debug(luaState);
+ }
+
///
/// Opens all standard Lua libraries into the given state.
+ /// Equivalent to calling luaL_openlibs
///
public void OpenLibs()
{
NativeMethods.luaL_openlibs(_luaState);
}
+ ///
+ /// Opens the base library (_G), registering core global functions
+ /// such as print, pairs, and type
+ ///
+ public void OpenBasicLibrary()
+ {
+ RequireF("_G", OpenBase, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the package library, enabling module loading via require
+ ///
+ public void OpenPackageLibrary()
+ {
+ RequireF("package", OpenPackage, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the coroutine library for cooperative multitasking
+ ///
+ public void OpenCoroutineLibrary()
+ {
+ RequireF("coroutine", OpenCoroutine, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the table library for table manipulation utilities
+ ///
+ public void OpenTableLibrary()
+ {
+ RequireF("table", OpenTable, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the I/O library for file operations
+ ///
+ public void OpenIOLibrary()
+ {
+ RequireF("io", OpenIO, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the OS library for operating system interactions
+ ///
+ public void OpenOSLibrary()
+ {
+ RequireF("os", OpenOS, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the string library for string manipulation functions
+ ///
+ public void OpenStringLibrary()
+ {
+ RequireF("string", OpenString, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the UTF-8 library for Unicode string handling
+ ///
+ public void OpenUTF8Library()
+ {
+ RequireF("utf8", OpenUTF8, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the math library for mathematical operations
+ ///
+ public void OpenMathLibrary()
+ {
+ RequireF("math", OpenMath, true);
+ Pop(1);
+ }
+
+ ///
+ /// Opens the debug library for advanced debugging and introspection
+ ///
+ public void OpenDebugLibrary()
+ {
+ RequireF("debug", OpenDebug, true);
+ Pop(1);
+ }
+
///
/// If the function argument arg is an integer (or convertible to an integer), returns this integer. If this argument is absent or is nil, returns d
///
diff --git a/src/NativeMethods.cs b/src/NativeMethods.cs
index dc7316e..42d44ef 100644
--- a/src/NativeMethods.cs
+++ b/src/NativeMethods.cs
@@ -442,6 +442,36 @@ internal static extern charptr_t luaL_traceback
[DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
internal static extern void luaL_where(lua_State luaState, int level);
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_base(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_package(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_coroutine(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_table(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_io(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_os(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_string(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_utf8(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_math(lua_State luaState);
+
+ [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int luaopen_debug(lua_State luaState);
+
#pragma warning restore CA2101 // Bug on CA + VS2017
#pragma warning restore IDE1006 // Naming Styles