Prompting my current EXP to the infobar

Posted by Kaimarae on Sun 15 May 2011 01:32 AM — 22 posts, 86,613 views.

#0
Hi all.

I currently have a system that captures my stats from the prompt and displays it on the infobar.
I would very much like to add my current experience to it, but I have to use SCORE to see my current experience. It looks like this:

Recruit Kaimarae (male Kingdom Human)
You are level 24 (Effervescent) and 52.75% of the way to the next level.
  Health:          924/924  Endurance:       235/235
  Magic:           964/964
You stand tall as a proud Peasant of Krondor.
You are a Runner in the Pathfinders, and 0% of the way to the next rank.
You are a Warlock Greater Path Magician.
You are a Landloper in the Fellowship of Explorers.
You are 17 years old, having been born on the 40th of Wochem, 1 years before the
Darkness at Sethanon.
You carry 25 copper in Kingdom currency.


Now, getting it to SCORE after each kill and capture the "52.75" with a wildcard is easy, currently doing that.. but results in a HUGE amount of screen space spammed with various things I don't care about.

I had an idea to get it to SCORE after each kill then save the information and omit it. But I still want to be able to check my score at other times.

My idea was to use a trigger to enable a Omit Score variable, which disables at the end but I'm not sure how to go about omitting AND still getting the experience percentage. Any ideas?
Australia Forum Administrator #1
You can still use information from a trigger if it is omitted, no problem there.

You really need four triggers in your case, I think. All usually disabled.

After a battle and you have sent "score" enable trigger #1 and #2.

Trigger #1 omits from output and enables triggers #3 and #4.

Trigger #2 omits from output and remembers your experience.

Triggers #3 and #4 omit from output.

Trigger #4 disables all four triggers (including itself) to revert to normal operation.


Trigger #1: match: Recruit Kaimarae (male Kingdom Human)

Trigger #2: match: You are level * (*) and *% of the way to the next level.

Trigger #3: match: *

Trigger #4: match: You carry * in Kingdom currency.


Make trigger #2 have a lower priority than trigger #3 so it detects the experience line before the "match all" line.
Amended on Sun 15 May 2011 03:59 AM by Nick Gammon
USA #2
Well, I just had a whole response typed up, but I hit the wrong button... :| ([EDIT]: Gah, Nick!)

Basically, you want to do the same thing as my MapWindow plugin. You have three triggers: a "start" trigger, a "middle" trigger that matches anything and everything, and an "end" trigger that matches the prompt. In your case, the "start" trigger would be:
^Recruit Kaimarae \(male Kingdom Human\)$

The "middle" and "end" triggers start out disabled. When the "start" trigger matches, it enables the two others (and optionally disables itself). The "middle" trigger gags everything. The "end" trigger disables itself and "middle", and re-enables "start".

It's important that all of these triggers have "Keep evaluating" checked, especially "middle". "Keep evaluating" tells MUSHclient to keep looking for other triggers that match the same line, and I recommend it be enabled for every trigger you ever create unless you have a good reason.

Once that's done, you can add a trigger for getting your experience, which you already have.
Amended on Sun 15 May 2011 04:01 AM by Twisol
#3
You people are legendary. Seriously. I cannot believe how useful this forum has been/is. Thank you so much :D

EDIT: When you say enables the triggers, is there a command (Lua) that enables other triggers... Currenly I'm just using variables set to 'true' or 'false' and using "if GetVariable("blahblah") == 'blah' then" statements. A command would be a lot simpler... Heh.
Amended on Mon 16 May 2011 01:38 AM by Kaimarae
USA #4
Yep. EnableTrigger("trigger's label", true) and EnableTrigger("trigger's label", false). You can also enable/disable a whole group using EnableTriggerGroup("group", true).
#5
That's pretty awesome. I love the simple Lua syntax. Everything just makes sense xD
Enable trigger? EnableTrigger.
Brilliant.
USA #6
And then you go to disable a trigger and use EnableTrigger. ~_^

(No, really, you can fix that: DisableTrigger = function(label) return EnableTrigger(label, false) end)
#7
That's pretty cool. Two things:

How do I set the priority? I thought it was Sequence... But that was mistaken. I think. Didn't work anyway.

It's all triggering and enabling/disabling just fine, but because I still want to check score, I made a trigger on "You have slain *" which enables the start trigger and does Send("SCORE"). Is it possible to hide the echo and therefore the extra line of prompt? Is a minor quibble.

Thanks lots :]
USA #8
Kaimarae said:
How do I set the priority? I thought it was Sequence... But that was mistaken. I think. Didn't work anyway.

A lower sequence actually means a higher priority, so a trigger with sequence 99 will always be processed before a trigger with sequence 100. Can you paste what you tried?
Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


Kaimarae said:
Is it possible to hide the echo

Yes, use SendNoEcho(). (This doesn't apply if it's the MUD that's sending the echo.)

Kaimarae said:
and therefore the extra line of prompt?

Do you mean the prompt that comes after the SCORE output? If you change your "end" trigger to the prompt instead of the final line of the SCORE, you'll gag the prompt as well.
#9
I went looking and found SendNoEcho myself actually. But the changing the end-trigger to the prompt I didn't think of. That works beautifully now.

This is what I tried:

Grab exp:
<triggers>
  <trigger
   group="Prompting"
   keep_evaluating="y"
   match="^You are level * and *% of the way to the next level\."
   name="EXPgrab2"
   omit_from_output="y"
   regexp="y"
   send_to="12"
   sequence="99"
  >
  <send>SetVariable("CurrentEXP", "%3")</send>
  </trigger>
</triggers>


Omit all else:
<triggers>
  <trigger
   enabled="y"
   group="Prompting"
   keep_evaluating="y"
   match="*"
   name="EXPgrab3"
   omit_from_output="y"
   send_to="12"
   sequence="100"
  >
  </trigger>
</triggers>


I tried different combinations of 99 and 100.

USA #10
Well, one's enabled by default and the other isn't. I think both should likely be disabled by default, and make sure you're enabling them both when the start trigger fires.
#11
Well, I found two things going wrong there...

Trigger #2 wasn't being enabled (duhhh... God) and it was trying to update CurrentEXP with "%3"... notice there are only two wildcards in my match line... Haha, fixed that, but it's still not happening... Hrm.
#12
In other news, I can't edit any of those triggers now... Just says:

Quote:
The trigger named "expgrab2" has already been modified by a script subroutine.


... The hell?

I wonder if the difference between "expgrab2" (what it's being called) and "EXPgrab2" (what it IS called) makes any difference...

EDIT: It uh... Stopped doing that. Nevermind. :/
Amended on Mon 16 May 2011 10:21 AM by Kaimarae
USA #13
Mind pasting the whole set of triggers, and an example SCORE output (plus prompt)?

[EDIT]: I also find it useful to stick to lowercase letters with underscores to avoid any accidents. :)
Amended on Mon 16 May 2011 10:25 AM by Twisol
#14
I think I've narrowed it down. Everything is working hunkey-dorey... EXCEPT the experience catching line isn't triggering (according to trace). Disabled trigger "*" to see if it was overriding, it isn't. Which meeeans my trigger is probably wrong. This is the line:

You are level 25 (Significant) and 34.46% of the way to the next level.


I'm trying to match with this:

^You are level * and *% of the way to the next level.$


I have also tried with:

^You are level * \(*\) and *\% of the way to the next level\.$


Any idea what I'm doing wrong? (Regular Expression is checked)

EDIT: Jeeeesus. Just copy/pasted the line exactly and it still isn't matching. :|
Amended on Mon 16 May 2011 10:36 AM by Kaimarae
USA #15
Kaimarae said:
^You are level * and *% of the way to the next level.$


Any idea what I'm doing wrong? (Regular Expression is checked)

Yeah, it's the mixture of basic patterns and regular expressions again. * alone is a basic pattern symbol for a match. In a regular expression it means something totally different ("zero or more of the character before this one").

^You are level \d+ \([^)]+\) and \d+(?:\.\d+)?% of the way to the next level\.$

Internally the basic-pattern * is converted to (.*?), but that's not always (read: rarely) optimal, so I took the liberty of making it match more exactly. \d means "a digit", and the + after it means "one or more". The bit after that matches anything in parentheses that isn't an end parenthesis, and then I match the experience (making the fractional part optional). I also escaped the .'s because . means "any character" in regexp.

You might want to check out a tutorial on regular expressions. They're pretty easy to understand once you've learned a bit of the syntax.

http://www.regular-expressions.info/tutorial.html

[EDIT]: Also, congratulations on levelling up since you started the thread. ;)
Amended on Mon 16 May 2011 10:52 AM by Twisol
#16
Woowoo! Matches. Now, one last question... What %# do I use to capture the percentage? ^_^;

EDIT: Regarding the level, thanks! It was a by-product of bashing things trying to get the triggers to work ;)
Amended on Mon 16 May 2011 10:51 AM by Kaimarae
USA #17
OOPS. I just edited my original post instead of quoting it! XD Luckily I could go back in my history and fish out the original... anyways, my response is below.

^You are level \d+ \([^)]+\) and (\d+(?:\.\d+)?)% of the way to the next level\.$


You can add parentheses around a piece of the expression to capture it. I bolded/underlined the changed part.
#18
So do I then use %1, or just Send To Variable? (Sorry if I'm a bit dense at times :P)
USA #19
"Send to" just tells MUSHclient what you want to do with the Send box. If it were set to "Variable", the contents of the Send box would be put in a variable. ;) You want Send to Script, using %1 in it for the capture.
#20
Yessss! Everything works beautifully. Thanks so much :D

/bow
USA #21
Glad to help!