Evaluating triggers with user-specified string from script?

Posted by j0nas on Tue 03 Jun 2003 11:19 AM — 8 posts, 30,233 views.

#0
Would it be possible for me to call a function from within a script, for example '$world->evaluatetriggers("You're hungry.");' and have MUSHClient react like it just recieved that very string from the world and evaluate it for trigger-matches and fire off scripts etc etc, just like it would do normally?

The reason I'm asking is that I've got a 200Mb+ log-file that I'd love to parse through my new MUSHClient-script and it's triggers, as if MUSHClient had just recieved those lines as input. Perhaps there's a much better way to do this though, I'm open to suggestions.
Greece #1
I don't know if that's possible, but it would be nice if you could do it. I could then easily write a search/replace plugin for searching in files using regex :p cool function...
Russia #2
well, the way I do it is by using Shadowfyr's Phantom server. What this little gadget does is simply echo whatever you type in the input window back to the output. So basically it's an echo server. The only drawback to this is that logfiles don't save all that ANSI markup, which is processed by MUclient behind the scenes, so you get prompts without normal colours, etc. Not a big deal though if all you want to do is test the scripts and triggers.

Search the forum for Phantom and you'll find a link to it.
After installing, run it, change the port number in it's little window to whatever you want, change the world's IP to localhost or 127.0.0.1 in your world settings and click on the connect button. Then just paste your file (probably will have to do it in chunks, since processing 1k lines normally takes around 10 seconds on my PII-200 and you don't want to crash your computer) into the input window and hit enter.
Australia Forum Administrator #3
What I did when I was benchmarking MUSHclient (timing it) was make a logfile like you describe, using the "raw log" ability.

Then I copied that to a Linux PC, logged in to it with MUSHclient (ie. connected using port 23) and then typed:

cat mylogfile

This basically sent the logfile to MUSHclient which then evaluated all its triggers etc.

If you don't have Linux handy, you could probably do the same thing with Cygwin, however I don't have that installed right now to say for sure. You would need the telnet daemon running (telnetd).

Or, get a Windows telnet daemon (eg. from TuCows) - I know there are some around - and do the same thing with that.

Failing that, take the "tiny mud server" I did (source on this site) and write a new command "test" that reads your log file in and sends the lot to the connected player.

#4
Oh yes, catting it from a linux-machine has to be the best solution for files this size. That'll be just perfect, thanks.
Greece #5
I just found out that VBScript has a regular expression object. Quoting the example from the scripting helpfile:
function matchDemo(){
var s;
var re = new RegExp("d(b+)(d)","ig");
var str = "cdbBdbsbdbdz";
var arr = re.exec(str);
s = "$1 contains: " + RegExp.$1 + "\n";
s += "$2 contains: " + RegExp.$2 + "\n";
s += "$3 contains: " + RegExp.$3;
return(s);
}
Australia Forum Administrator #6
Yes, there are a few posts here about using that. Handly if you want more than 10 wildcards, for example.

However the original post was to see what his existing triggers did with a log file, and unless you recoded each trigger using the VBscript regexp parser, it wouldn't quite do that.
Canada #7
For anybody interested in Shadowfyr's program, I am currently hosting it here:

http://www.MagnumsWorld.com/Muds/