More lua functions.
This commit is contained in:
parent
5172f9e397
commit
7430a35806
|
@ -12,10 +12,17 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
Lua lua = new Lua();
|
Lua lua = new Lua();
|
||||||
LuaWindow Caller;
|
LuaWindow Caller;
|
||||||
|
public static string[] MemoryFunctions = new string[] {
|
||||||
|
"readbyte",
|
||||||
|
"writebyte"};
|
||||||
public LuaImplementation(LuaWindow passed)
|
public LuaImplementation(LuaWindow passed)
|
||||||
{
|
{
|
||||||
Caller = passed.get();
|
Caller = passed.get();
|
||||||
lua.RegisterFunction("print",this, this.GetType().GetMethod("print"));
|
lua.RegisterFunction("print",this, this.GetType().GetMethod("print"));
|
||||||
|
for (int i = 0; i < MemoryFunctions.Length; i++)
|
||||||
|
{
|
||||||
|
lua.RegisterFunction(MemoryFunctions[i], this, this.GetType().GetMethod(MemoryFunctions[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void DoLuaFile(string File)
|
public void DoLuaFile(string File)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +30,28 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
public void print(string s)
|
public void print(string s)
|
||||||
{
|
{
|
||||||
Caller.AddText(s);
|
Caller.AddText(string.Format(s));
|
||||||
|
}
|
||||||
|
public string readbyte(object lua_input)
|
||||||
|
{
|
||||||
|
|
||||||
|
byte x;
|
||||||
|
if (lua_input.GetType() == typeof(string))
|
||||||
|
{
|
||||||
|
x = Global.Emulator.MainMemory.PeekByte(int.Parse((string)lua_input));
|
||||||
|
return x.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double y = (double)lua_input;
|
||||||
|
x = Global.Emulator.MainMemory.PeekByte(Convert.ToInt32(y));
|
||||||
|
return x.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void writebyte(object lua_input)
|
||||||
|
{
|
||||||
|
Global.Emulator.MainMemory.PokeByte((int)lua_input, (byte)lua_input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace BizHawk.MultiClient.tools
|
||||||
{
|
{
|
||||||
OpenFileDialog fdlg = new OpenFileDialog();
|
OpenFileDialog fdlg = new OpenFileDialog();
|
||||||
fdlg.Title = "Open Lua Script";
|
fdlg.Title = "Open Lua Script";
|
||||||
fdlg.InitialDirectory = @"c:\"; //Switch this to a better default directory
|
fdlg.InitialDirectory = @".\"; //Switch this to a better default directory
|
||||||
fdlg.Filter = "Lua files (*.lua)|*.lua|All files (*.*)|*.*";
|
fdlg.Filter = "Lua files (*.lua)|*.lua|All files (*.*)|*.*";
|
||||||
fdlg.FilterIndex = 1;
|
fdlg.FilterIndex = 1;
|
||||||
fdlg.RestoreDirectory = true;
|
fdlg.RestoreDirectory = true;
|
||||||
|
|
Loading…
Reference in New Issue