The first method is to hook the "EQ Chat" events in ISXEQ within the .NET application and then applying regular expressions to the text, matching on your events of interest.
The second method is to define a custom event within a lavishscript script and tie that event to a trigger. Inside the .NET application you hook the custom event. This method frees you from parsing the text inside the .NET application.
The ISXEQ.NET.dll was built using Visual Studios Express 2005 for C++ and placed into the InnerSpace directory.
The example was built using Visual Studios 2008 Express for C#. I created a console project, targetted the runtime as .NET 2.0 and had the following for References:
ISXEQ.NET
Lavish.InnerSpace
System
Place all 3 of the files in your InnerSpace/scripts directory
Program.cs
Code: Select all
using System;
using System.Threading;
using System.Text.RegularExpressions;
using LavishScriptAPI;
using IS = InnerSpaceAPI.InnerSpace;
namespace Example
{
class Program
{
private const String testEventRegex = @".*fire test event 1 :([^:]+):.*";
private static void EQChatText(object sender, LSEventArgs e)
{
String chatText = Convert.ToString(e.Args[0]);
Match eventMatch = Regex.Match(chatText, testEventRegex);
if (eventMatch.Success)
{
IS.Echo("Test event 1 matched, param is " + eventMatch.Groups[1]);
}
}
private static void TestEvent2(object sender, LSEventArgs e)
{
string param = Convert.ToString(e.Args[0]);
IS.Echo("Test event 2 matched, param is " + param);
}
static void Main()
{
LavishScriptAPI.LavishScript.Events.AttachEventTarget("EQ Chat", EQChatText);
LavishScriptAPI.LavishScript.Events.AttachEventTarget("Test Event 2", TestEvent2);
Thread.Sleep(60000);
LavishScriptAPI.LavishScript.Events.DetachEventTarget("EQ Chat", EQChatText);
LavishScriptAPI.LavishScript.Events.DetachEventTarget("Test Event 2", TestEvent2);
LavishScriptAPI.LavishScript.ExecuteCommand("echo ending event testing");
}
}
}
Code: Select all
<DotNetScript>
<References>
<string>Lavish.InnerSpace.dll</string>
<string>ISXEQ.NET.dll</string>
<string>C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll</string>
</References>
<SourceFiles>
<string>Program.cs</string>
</SourceFiles>
<Language>C#</Language>
</DotNetScript>
testevent.iss
Code: Select all
#macro ProcessQueue()
if ${QueuedCommands}
while ${QueuedCommands}
ExecuteQueued
#endmac
function Event_TestEvent2(string line, string param)
{
echo "Test Event 2 Fired (lavish script): [${param}]"
Event[Test Event 2]:Execute[${param}]
}
function main()
{
ext -require isxeq
AddTrigger Event_TestEvent2 "@*@fire test event 2 :@param@:@*@"
LavishScript:RegisterEvent[Test Event 2]
do
{
ProcessQueue()
WaitFrame
wait 5
}
while ${Spawn[${Me}](exists)}
}
function atexit()
{
Event[Test Event 2]:Unregister
echo ${Script.Filename}.iss ended
}
fire test event 1 :<param to parse out>:
OR
fire test event 2 :<param to parse out>:
Test event 1 fires by hooking the EQ Chat events and matching a regular expression: private const String testEventRegex = @".*fire test event 1 :([^:]+):.*";
The method EQChatText is tied to all incomming EQ chat events. When the regular expression is matched, the param is parsed out and output: IS.Echo("Test event 1 matched, param is " + eventMatch.Groups[1]);
Test event 2 fires because the lavishscript script defines a new event: LavishScript:RegisterEvent[Test Event 2] and ties this event firing to a trigger:
...
function Event_TestEvent2(string line, string param)
{
Event[Test Event 2]:Execute[${param}]
...
AddTrigger Event_TestEvent2 "@*@fire test event 2 :@param@:@*@"
The method TestEvent2 is tied to the event firing in the .NET application by: LavishScriptAPI.LavishScript.Events.AttachEventTarget("Test Event 2", TestEvent2);
spanners
