refactor lua scripts to be more flexible
This commit is contained in:
parent
b64ee06a8c
commit
bc3e8606a2
|
@ -20,7 +20,7 @@ namespace BizHawk.MultiClient
|
|||
public EventWaitHandle LuaWait;
|
||||
public bool isRunning;
|
||||
private int CurrentMemoryDomain = 0; //Main memory by default
|
||||
List<Lua> runningThreads = new List<Lua>();
|
||||
//List<Lua> runningThreads = new List<Lua>();
|
||||
Lua currThread;
|
||||
|
||||
public LuaImplementation(LuaConsole passed)
|
||||
|
@ -34,7 +34,6 @@ namespace BizHawk.MultiClient
|
|||
public void Close()
|
||||
{
|
||||
lua = new Lua();
|
||||
runningThreads.Clear();
|
||||
}
|
||||
|
||||
public void LuaRegister(Lua lua)
|
||||
|
@ -105,13 +104,14 @@ namespace BizHawk.MultiClient
|
|||
LuaLibraryList += "client." + MultiClientFunctions[i] + "\n";
|
||||
}
|
||||
}
|
||||
public void DoLuaFile(string File)
|
||||
|
||||
public Lua SpawnCoroutine(string File)
|
||||
{
|
||||
var t = lua.NewThread();
|
||||
runningThreads.Add(t);
|
||||
LuaRegister(t);
|
||||
var main = t.LoadFile(File);
|
||||
t.Push(main); //push main function on to stack for subsequent resuming
|
||||
return t;
|
||||
}
|
||||
|
||||
private int LuaInt(object lua_arg)
|
||||
|
@ -141,14 +141,11 @@ namespace BizHawk.MultiClient
|
|||
return lua_result;
|
||||
}
|
||||
|
||||
public void ResumeScripts()
|
||||
public void ResumeScript(Lua script)
|
||||
{
|
||||
foreach (var t in runningThreads)
|
||||
{
|
||||
currThread = t;
|
||||
t.Resume(0);
|
||||
currThread = null;
|
||||
}
|
||||
currThread = script;
|
||||
script.Resume(0);
|
||||
currThread = null;
|
||||
}
|
||||
|
||||
public void print(string s)
|
||||
|
|
|
@ -5,29 +5,35 @@ using System.Text;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
class LuaFiles
|
||||
class LuaFile
|
||||
{
|
||||
public string Name;
|
||||
public string Path;
|
||||
public bool Enabled;
|
||||
public bool IsSeparator;
|
||||
public LuaInterface.Lua Thread;
|
||||
|
||||
public LuaFiles(string path)
|
||||
public LuaFile(string path)
|
||||
{
|
||||
Name = "";
|
||||
Path = path;
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
public LuaFiles(string name, string path, bool enabled)
|
||||
public void Stop()
|
||||
{
|
||||
Enabled = false;
|
||||
Thread = null;
|
||||
}
|
||||
|
||||
public LuaFile(string name, string path)
|
||||
{
|
||||
Name = name;
|
||||
Path = path;
|
||||
Enabled = enabled;
|
||||
IsSeparator = false;
|
||||
}
|
||||
|
||||
public LuaFiles(bool isSeparator)
|
||||
public LuaFile(bool isSeparator)
|
||||
{
|
||||
IsSeparator = isSeparator;
|
||||
Name = "";
|
||||
|
@ -35,7 +41,7 @@ namespace BizHawk.MultiClient
|
|||
Enabled = false;
|
||||
}
|
||||
|
||||
public LuaFiles(LuaFiles l)
|
||||
public LuaFile(LuaFile l)
|
||||
{
|
||||
Name = l.Name;
|
||||
Path = l.Path;
|
||||
|
|
Loading…
Reference in New Issue