by Frobisher » Wed May 31, 2006 12:24 pm
Here's a script that will work with Wintin 2.x - it needs C# scripting which isn't available in v1.
To use the script, right click in the Script Manager and create a new alias. Call it eqlist or anything else you want. Copy and paste the text below into the alias properties box, and select C# as the script language.
With the alias defined, you can say for example 'eqlist diamond' to get a list of all the diamond thingies.
For the time being this is pointing at the backup eq list as there is a problem with the slothmud one. Just change the url in the listing below when Shiv has fixed the problem.
[code:1byr8p9k] Editor's Note: the problem has been fixed.
[/code:1byr8p9k]
regards
Fro
[code:1byr8p9k]
using System;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using System.Net;
using ScriptEngine;
//css_reference ScriptEngine.dll;
public class Script : WintinScript
{
public override void Init()
{
string line = wintin.Line.Trim();
string url = "http://www.slothmud.org/eqlist/xml.php?eqname=" + line;
WebRequest req;
Stream st = null;
XmlTextReader xr = null;
try
{
req = WebRequest.Create(url);
WebResponse resp = req.GetResponse();
st = resp.GetResponseStream();
xr = new XmlTextReader(st);
string eqname, type, armor, affects, res;
while(xr.Read())
{
xr.MoveToElement();
if(xr.Name == "eq" && xr.NodeType == XmlNodeType.Element)
{
eqname = "";
type = "";
armor = "";
affects = "";
do
{
xr.Read();
if(xr.NodeType == XmlNodeType.Element)
{
if(xr.Name == "eqname")
eqname = xr.ReadElementString();
if(xr.Name == "type")
type = xr.ReadElementString();
if(xr.Name == "armor")
armor = xr.ReadElementString();
if(xr.Name == "affects")
affects = xr.ReadElementString();
}
}
while(xr.Name != "eq" || xr.NodeType != XmlNodeType.EndElement);
res = eqname + " (" + type + ") " + armor + " " + affects + "\r\n";
wintin.SendToScreen(res);
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if(st != null)
st.Close();
if(xr != null)
xr.Close();
}
}
}[/code:1byr8p9k]