Browse Source

feat: add methods to create threads and coroutines in LuaState

Akeit0 4 months ago
parent
commit
d07bd4de91
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/Lua/LuaState.cs

+ 12 - 1
src/Lua/LuaState.cs

@@ -32,7 +32,7 @@ public class LuaState : IDisposable
         globalState = LuaGlobalState.Create();
         return globalState.MainThread;
     }
-    
+
     public static LuaState Create(LuaPlatform platform)
     {
         return LuaGlobalState.Create(platform).MainThread;
@@ -43,6 +43,17 @@ public class LuaState : IDisposable
         return new(globalState, function, isProtectedMode);
     }
 
+    public LuaState CreateThread()
+    {
+        return new(GlobalState);
+    }
+
+    public LuaState CreateCoroutine(LuaFunction function, bool isProtectedMode = false)
+    {
+        return new(GlobalState, function, isProtectedMode);
+    }
+
+
     public LuaThreadStatus GetStatus()
     {
         if (coroutine is not null)