Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Tips and tricks
➜ regexp magic
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Xargus
(3 posts) Bio
|
| Date
| Wed 19 Dec 2007 08:09 PM (UTC) |
| Message
| 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 | | Top |
|
| Posted by
| Xargus
(3 posts) Bio
|
| Date
| Reply #1 on Wed 19 Dec 2007 08:45 PM (UTC) |
| Message
| 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 ;)
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Thu 20 Dec 2007 01:02 AM (UTC) |
| Message
| 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)$
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,380 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top