Script Errors Now Appears In OutputBox.

This commit is contained in:
rolanmen1 2012-03-25 09:47:31 +00:00
parent d3321f552f
commit 75c0a9f7d3
4 changed files with 49 additions and 49 deletions

View File

@ -115,22 +115,9 @@ namespace BizHawk.MultiClient
public Lua SpawnCoroutine(string File) public Lua SpawnCoroutine(string File)
{ {
var t = lua.NewThread(); var t = lua.NewThread();
try LuaRegister(t);
{ var main = t.LoadFile(File);
LuaRegister(t); t.Push(main); //push main function on to stack for subsequent resuming
var main = t.LoadFile(File);
t.Push(main); //push main function on to stack for subsequent resuming
}
catch (Exception e)
{
if (e.ToString().Substring(0, 32) == "LuaInterface.LuaScriptException:")
{
//Create Code Here That Would Print Script Error In OutPut Box
LuaConsole Lua = new LuaConsole();
Lua.OutputBox.Text += e.Message;
}
else MessageBox.Show(e.ToString());
}
return t; return t;
} }

View File

@ -212,8 +212,8 @@
// //
this.openSessionToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile; this.openSessionToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.OpenFile;
this.openSessionToolStripMenuItem.Name = "openSessionToolStripMenuItem"; this.openSessionToolStripMenuItem.Name = "openSessionToolStripMenuItem";
this.openSessionToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) this.openSessionToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.O))); | System.Windows.Forms.Keys.O)));
this.openSessionToolStripMenuItem.Size = new System.Drawing.Size(237, 22); this.openSessionToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.openSessionToolStripMenuItem.Text = "&Open Session..."; this.openSessionToolStripMenuItem.Text = "&Open Session...";
this.openSessionToolStripMenuItem.Click += new System.EventHandler(this.openSessionToolStripMenuItem_Click); this.openSessionToolStripMenuItem.Click += new System.EventHandler(this.openSessionToolStripMenuItem_Click);
@ -230,8 +230,8 @@
// saveAsToolStripMenuItem // saveAsToolStripMenuItem
// //
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.S))); | System.Windows.Forms.Keys.S)));
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(237, 22); this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.saveAsToolStripMenuItem.Text = "Save Session &As..."; this.saveAsToolStripMenuItem.Text = "Save Session &As...";
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click); this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);

View File

@ -41,7 +41,7 @@ namespace BizHawk.MultiClient
public void AddText(string s) public void AddText(string s)
{ {
OutputBox.Text += s; OutputBox.Text += s + "\n\n";
} }
public LuaConsole() public LuaConsole()
@ -255,17 +255,29 @@ namespace BizHawk.MultiClient
private void RunLuaScripts() private void RunLuaScripts()
{ {
for (int x = 0; x < luaList.Count; x++) for (int x = 0; x < luaList.Count; x++)
{ {
if (luaList[x].Enabled && luaList[x].Thread == null) if (luaList[x].Enabled && luaList[x].Thread == null)
{ {
luaList[x].Thread = LuaImp.SpawnCoroutine(luaList[x].Path); try
} {
else luaList[x].Thread = LuaImp.SpawnCoroutine(luaList[x].Path);
{ }
StopScript(x); catch (Exception e)
} {
} if (e.ToString().Substring(0, 32) == "LuaInterface.LuaScriptException:")
{
luaList[x].Enabled = false;
AddText(e.Message);
}
else MessageBox.Show(e.ToString());
}
}
else
{
StopScript(x);
}
}
} }
private void UpdateNumberOfScripts() private void UpdateNumberOfScripts()
@ -338,8 +350,8 @@ namespace BizHawk.MultiClient
if (result == true || suppressAsk) if (result == true || suppressAsk)
{ {
ClearOutput();
StopAllScripts(); StopAllScripts();
ClearOutput();
luaList.Clear(); luaList.Clear();
DisplayLuaList(); DisplayLuaList();
UpdateNumberOfScripts(); UpdateNumberOfScripts();
@ -550,7 +562,7 @@ namespace BizHawk.MultiClient
LoadLuaSession(filePaths[0]); LoadLuaSession(filePaths[0]);
DisplayLuaList(); DisplayLuaList();
UpdateNumberOfScripts(); UpdateNumberOfScripts();
ClearOutput(); //ClearOutput();
} }
} }
@ -654,7 +666,7 @@ namespace BizHawk.MultiClient
OutputBox.Invoke(() => OutputBox.Invoke(() =>
{ {
OutputBox.Text += message; OutputBox.Text += message + "\n\n";
OutputBox.Refresh(); OutputBox.Refresh();
}); });
} }
@ -688,6 +700,7 @@ namespace BizHawk.MultiClient
var file = new FileInfo(path); var file = new FileInfo(path);
if (file.Exists == false) return false; if (file.Exists == false) return false;
ClearOutput();
StopAllScripts(); StopAllScripts();
luaList = new List<LuaFile>(); luaList = new List<LuaFile>();
@ -740,7 +753,6 @@ namespace BizHawk.MultiClient
RunLuaScripts(); RunLuaScripts();
DisplayLuaList(); DisplayLuaList();
UpdateNumberOfScripts(); UpdateNumberOfScripts();
ClearOutput();
} }
} }
@ -748,7 +760,7 @@ namespace BizHawk.MultiClient
{ {
OpenLuaSession(); OpenLuaSession();
} }
/// <summary> /// <summary>
/// resumes suspended coroutines /// resumes suspended coroutines
/// </summary> /// </summary>
@ -934,7 +946,7 @@ namespace BizHawk.MultiClient
RunLuaScripts(); RunLuaScripts();
DisplayLuaList(); DisplayLuaList();
UpdateNumberOfScripts(); UpdateNumberOfScripts();
ClearOutput(); //ClearOutput();
changes = false; changes = false;
} }
} }

View File

@ -133,17 +133,18 @@
<data name="openToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="openToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJQSURBVDhPlZNdSNNRGMb/F110ZZEVhVBgeeHNICiiuggp YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAlpJREFUOE+tk21I
olAUyyxI0oSaH1QYC3N+tKnp5ubm1JUua5uuqdPKMgr7kApFItTUkWZqVhSVYmao5Nev/xyoQ4k88Nyc k1EYhif0oyA0sqIQCix/+GcQFFH9CCmiUBTLLEjShJofVBgL2fxoU9Pp5ubUlS5rU9f8rCyjsA+pUCRC
8z6/93nP4QjCfy6lwc4ltZVso4P/tMyXRcmMHqZ0EeY6jZQVInzuf0e1Tb9Ina3P/tkpLD6XkNg8BJe5 TR1ppmVFUSlmhq78unrnQF1KGHTg/nEOz30993PO+7qJFrmUeiv2n+Mij+XLRLLYULdF2pxlEVIDcw0p
u93C+HDVrP4M2ZkcMOOw5tLZ9nxJyJE4HSExBoKkBQhVpTrGhso9zNPfiph0JlB+U01ZcRbmwnRMeWlc AsyxD5fmI/rQ94pqi26eOlsfuZj+7BgSm01QdA4ih7m73Yx9qGpavwatjPebqCzOprPt8YKQgzFagqL0
08opUCV6QissGsZ+WOY6z4hmuuXglC6pRYBbJSp+fzXNxnaZ66o1s3rkyKHWruJuWRYOcwZ2kxKr8TI3 BEjyEFWVaBkdLHMxT34uYNwWR9nVTEoL0zHlp2DMSeaSRk6eKt4VWm5WM/rVPNN5SjDTLQebZEHNA1wr
DCkU6+QYNUnuNGWmLEY+5uOK3degoKZcx3SfEvozPfVB3OtNhi4ZvI2nrTIc23U9gtmYwa8eNXzScq8i UvHjk3E6tsNcV62e1r3KLGqtKm6WplNpSsVqVFJsOM8VfSKFWjkGtcyZptSYzvC7XByx3zQoqCnTMvlG
l6bHWnfRwhHeREJzGFONgYw/CeB9qQSZNNR9FyUGBT87lfQ3plJj1zLTq4COGDegLVo0HmeqKZjx+gOM CX1prnornPUmQJcUXsbSVhGK5bIOkcmQyveeTHiv4VZ5Nk33Nc6iuSO8CIfmECYa/bE/8ON1iRipJNh5
PNzDYPU2lLF+4jhyN6BIl8pgexK3bRpaXopJuhJEwGloiWDmVSgTLw4xWreXoZrtfK/wp/nKak4E+s6/ F0V6Bd86lfQ1JlFj1TDVq4COKCegLVIwHmGiKRB7/V6G7+5koHozymgfYRy5E1CgTWKgXcZ1i5qWp0KS
hDFHTkd9GndsOdCTBq1i3NdHmWgIYvRpAMO1OxlwSPhi2YpT641CuoWzsSfnAfnZiVRZ1Tjvx9GsF+bU rjgBcAJawph6FszYk/2M1O1isGYLX8p9ab6wgqP+3rMvYciS01GfzA1LFvQkQ6sQ9/khxhoCGHnox1Dt
pF1BvWolD9JXUZmyDnOiD1cvbCZiYXfXCPrMi+gVZ8hOiiL53DHORwdzKnw/hw/uYt9uCTskfvj7+rBp NvorxXw0b8Km8UQh2cip6GOzgNyMeKqKM7HdjqFZJ5pRk2YJ9aql3EnxoCJxNaZ4Ly6e3UDY3O6OEXRp
41rWr/Fig7fX8j/Tsn/fcgx/ARfG3ml6M3rzAAAAAElFTkSuQmCC 59ApTpIhiyDh9GHORAZyPHQPB/ZtZ/cOMVvFPvh6e7F+3SrWrHRnraf7Xz/xf/rJ/kvxb84I3U1y+9/W
AAAAAElFTkSuQmCC
</value> </value>
</data> </data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">