regexp magic

Posted by Xargus on Wed 19 Dec 2007 08:09 PM — 3 posts, 14,037 views.

#0
Hi,
This is the beginning of what will be several posts. I hope to provid all needed information on the first pass... but may fail at that. ;)

prompts on nilgiri vary with class and current position. Here's one that works most of the time for my mage.
"^\< (.{1,3}h|.{1,3}hIt) (.{1,3}m|.{1,3}MaNa) (.{1,3}v|.{1,3}mOVe) (sitting \>|resting \>|sleeping \>|\>)" >
The prompt line itself is:
< ###h ###m ###v >
That is it's simplest form. When intoxicated it goes to the longer form:
< ###hIt ###mANa ###mOVe >

For non mana using classes the simple form is:
< ###h ###v >
Since intoxication does not help anything but mana regen, my non-mana using chars don't drink so I do not care about the intoxicated version and actually have never seen it ;)

Using the non-mana version I will now seek to show the other issues:< 100h 112v sitting > This is sitting in it's simplest form, which I have addressed above with the mana users.
< 100h 112v sitting on a bench > This is the longer form that I wished addressed.

So, my questions:
1. How best to address sitting/resting/sleeping on objects that may vary?
2. Is it possible to consolidate the regexp into a single case that handles both chars with and without mana and those drunken clerics of mine?

I use this to add a linefeed after the prompt so that everything processes nicely. Also, an example naming hp, mana, and move would be nice as well.
I do not foresee a need to know what i'm parked on so in non-regexp terms sit* > or rest* > or sleep* > would be great. Along with the imbedded mana that may or may not be present.
Thanks!
Cecil
#1
Hi,
and for my next concern, I am working in lua attempting to validate that spells are cast correctly or recast if failed. I have the following lines defined:
local sF1 = "You lost your concentration\!"
local sF2 = "You forgot the words\!"
local sF3 = "Ooops\.\. that didn't work\!"
local sF4 = "Ack\.\. got some phlegm in your throat\!"
local sF5 = "Your magic seems to be absorbed by this air\!"

These are all the generic failure messages and I wish to do the following or something similar:
Spell_Failure = (sF1 .. "|" .. sF2 .. "|" .... "|" .. sF5)
My question is can I use a variable such as Spell_Failure as the match for a trigger? I can always wrap it as an entity as long as it's properly escaped and put it in an xml header and use it that way? I know i'll have to do something like:
^(Ok\.|Spell_Failure)$

for the final form trigger line since i'll want to match success and/or failure for particular spells anyway. I've been drooling over wait.regexp, but i'm still not sure how to properly use it in a real world example. And the thought of it spinng out of control in the background gives me nightmares ;)
Australia Forum Administrator #2
You can use variables in trigger matching provide you check "expand variables" but they are MUSHclient variables, not Lua variables. You might need to do this:


SetVariable ("Spell_Failure", Spell_Failure)


That copies the Lua Spell_Failure variable to the MUSHclient one.

Then in the trigger match you would need to expand it without having special characters escaped, like this:


Match: ^(Ok\.|@!Spell_Failure)$