Register forum user name Search FAQ

Gammon Forum

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 ➜ Suggestions ➜ Single word trigger highlighting please!!!

Single word trigger highlighting please!!!

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by David B   USA  (80 posts)  Bio
Date Wed 19 Feb 2003 01:55 PM (UTC)
Message
Ok. I think the subject says it all.

Groups gainable here:
Name Cost Name Cost
Skills gainable here:
Name Cost Lvl Name Cost Lvl
advanced flail 6 24 advanced mace 4 24
advanced sword 4 24 advanced whip 7 24
flail 5 1 whip 6 1
expert dagger 3 36 expert mace 4 36
expert sword 5 36 expert whip 6 36
master dagger 4 48 archery 6 16
fencing 3 17 unarmed block 6 32
belching 1 1 drinking 3 1
smoking 3 1 drink mixing 1 1
dual wield 4 45 fire building 3 1
unarmed combat 4 27 hunt 4 20
shield block 5 3 sharpening 5 43
third attack 7 24 crossbow 6 20
mountaineering 3 39 powder 5 11
appraisal 2 3 skinning 3 1
hearing 3 15 leadership 3 29
leather working 3 27 mining 3 5
pottery 1 4 singing 6 1
smithing 2 17 sewing 2 4
jewelry craft 3 15 weapon craft 5 8
metallurgy 4 2 tanning 4 4
smooth talk 3 58 spelunking 3 26
staves 5 9 vault wisdom 3 77
wands 5 9 orcish 1 1
vulcanian 1 1 entropic 1 1
taurian 1 1 dwarven 1 1
slaan 1 1 gnomish 1 1
Syntax:gain <skill/group>

I need to highlight a skill on this gain list, but I do not want to highlight the entire line.

My class is a thief. I need to beable to highlight certain skills i need to gain as I level up. I need 'smooth talk 3 58' But I do not want to highlight Spelunking, it does me no good.

I searched for highlighting and it was FAR FAR too complicated, and time consuming for me to setup for each indivual classes and what not.

Please add this capability, your client is the best, has been the best for me since, only god who knows when, I started using it, 2.15 now that I think about it, or somewhere around there.

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #1 on Wed 19 Feb 2003 08:30 PM (UTC)
Message
What might work better than highlighting the skills you want is gagging the skills you dont want. Granted, its almost as ugly to code but then again, anything that manipulates output from the mud is more difficult than simple triggers to react to that same output. Highlighting isnt a simple process because it essentially gags the original output, processes whatever changes you want for easier reading, and outputs the modified text.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #2 on Wed 19 Feb 2003 08:40 PM (UTC)

Amended on Wed 19 Feb 2003 08:41 PM (UTC) by Shadowfyr

Message
Not really that hard. Use a regular expression like:

^(master dagger|appraisal|smooth talk) \d+ \d+

Then just add new things into the () section as needed. This would hilight any one of the matching names and the two values after them.

You could also create a few aliases to add, remove and list them that call these subs (the trigger edit field gets crowded with more than a handful of match possibilities. lol):
sub Addskill(aname, output, wilds)
  dim tcolor = 1 'Change this to the custom color you use. 
  dim Temp
  Temp = GetTriggerInfo("SkillHlt", 1) 'Get match text.
  dim p1, p2, T1, T2, T3
  p1 = instr(Temp, "(")
  p2 = instr(Temp, ")")
  T1 = left(Temp, p1)                  'Get the first bit.
  T2 = mid(Temp, p1 + 1, p2 - p1 - 1)  'Get our list of skills.
  T3 = right(Temp, len(Temp) - p2 + 1) 'Get the last bit.
  dim fnd
  fnd = 0
  if T2 = "" then 'No skills, so just add it.
    T2 = wilds(1)
  else
    dim Skills, count
    Skills = split(T2,"|") 'Split into an array then check if already in list.
    for count = 0 to ubound(Skills) 'Loop through all the skills we have in the list.
      if Skills(count) = wilds(1) then
        fnd = 1
      end if
    next
    if fnd = 0 then
      T2 = T2 + "|" + wilds(1)
    else
      world.colournote "red", "black", "That skill is already being tested for."
      world.note " "
    end if
  end if
  if fnd = 0 then
    world.addtrigger "SkillHlt", T1 & T2 & T3, "", 1065, tcolor, 0, "", "", 0, 100 
    world.note wilds(1) & " added to hilight list."
    world.note " "
  end if
end sub

sub Remskill(aname, output, wilds)
  dim tcolor = 1 'Change this to the custom color you use. 
  dim Temp
  Temp = GetTriggerInfo("SkillHlt", 1)
  dim p1, p2, T1, T2, T3
  p1 = instr(Temp, "(")
  p2 = instr(Temp, ")")
  T1 = left(Temp, p1)
  T2 = mid(Temp, p1 + 1, p2 - p1 - 1)
  T3 = right(Temp, len(Temp) - p2 + 1)
  if T2 > "" then
    dim Skills, count, fnd
    Skills = split(T2,"|")
    fnd = 0
    for count = 0 to ubound(Skills)
      if Skills(count) <> wilds(1) then
        if count > 0 then
          T2 = T2 + "|" + Skills(count)
        else
          T2 = Skills(count)
        end if
      else
        fnd = 1
      end if
    next
    if fnd = 1 then
      world.addtrigger "SkillHlt", T1 & T2 & T3, "", 1065, tcolor, 0, "", "", 0, 100
      world.note wilds(1) & " successfully removed."
      world.note " "
    else
      world.colournote "red", "black", wilds(1) & " not found in list."
      world.note " "
    end if
  else
    world.colournote "red", "black", "There are no skills to remove."
    world.note " "
  end if
end sub

sub ListHlt (aname, output, wilds)
  Temp = GetTriggerInfo("SkillHlt", 1)
  dim p1, p2, T1, T2, T3
  p1 = instr(Temp, "(")
  p2 = instr(Temp, ")")
  T2 = mid(Temp, p1 + 1, p2 - p1 - 1)
  if T2 = "" then
    world.note "Nothing to list."
  else
    dim count, Skills
    Skills = split(T2, "|")
    for count = 0 to ubound(Skills)
      world.tell Skills(count) & space(20 - len(Skills)
      if (count + 1)/3 = int((count + 1)/3) then 'This gives us 3 skills per line when displayed.
        world.note " "
      end if
    next
    world.note " "
end sub


I haven't testing this, so there could be bugs in them. ;) They need to have the trigger added 'before' they will work, since they rely on T1 and T3 being taken from the trigger text. If you replaced those lines with T1 = "^(" and T3 = ") \d+ \d+" in the first sub then it 'may' in theory be able to create the trigger even if not already present, but I am not entirely certain.

In any case, you can match more than one possibility in a single trigger, having aliases to manage it is just a bit easier. ;)
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #3 on Thu 20 Feb 2003 03:20 PM (UTC)

Amended on Thu 20 Feb 2003 05:37 PM (UTC) by David B

Message
Its been a while, I'm seriously rusty with my vbscript.

Your post about the code I semi-understand what that code does is allows me to add or remove skills from the regular expression trigger that you mentioned. I was under the impression that even if I didn't do that code, the way you setup that trigger it should work.


The trigger didn't seem to work for me...

I might be doing something wrong with the trigger.

match on:^(master dagger|appraisal|smooth talk) \d+ \d+
checked: Enabled, regular expression.
all else unchecked
Colour: custom colour 1

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #4 on Thu 20 Feb 2003 05:45 PM (UTC)

Amended on Thu 20 Feb 2003 05:56 PM (UTC) by David B

Message
Ok well I got it to work *cheers*

Several small things about that trigger:

^(master dagger|appraisal|smooth talk) \d+ \d+

First, not all of the skills start the line so we can drop the ^. :)

(master dagger|appraisal|smooth talk) \d+ \d+

Secondly, I don't freaking know what the \d+ \d+ is
do I dropped that too. :)

(master dagger|appraisal|smooth talk)

This highlighted the skill names, but not the cost or the level. so I added this:

(master dagger|appraisal|smooth talk) (.*) (.*)

Ding ding ding, we have a winner!!!

Of course 3 minutes later, I find out that it still highlights the entire line behing it. because of the wild cards... Ok so wildcards won't work.... I just need some help in figuring out how to make it match on those numbers withuot it being a wild card, because everything after the first wilcard then becomes a wild card

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #5 on Thu 20 Feb 2003 07:02 PM (UTC)
Message
\d+ means, "one or more digits". Using them instead of the normal .* wildcard means it should only match where the result is 'skill_name cost level' In other words it would hilight the skill and numbers in a sentence like 'My skill is - appraisal 3 5' but not in 'Do you have appraisal or not?'. You should have left those in there. ;) lol
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #6 on Thu 20 Feb 2003 08:26 PM (UTC)
Message
Well... Once you get a skill, its removed from the list.

With the \d+ the trigger does not work.
Without it, it does. The cost, and level for the skill is not necessary, but it'd be nice, I can live without it.

I just wanna highlight the skills I need to gain, without the higligh its a pain in the arse to search for the skills you want. with it highlighted against the rest, they pop out easy and I can find the ones i want much more quickly.

If you can think of something other than \d+ Perhaps [d]+ would work better? I don't know.

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #7 on Fri 21 Feb 2003 07:21 AM (UTC)

Amended on Fri 21 Feb 2003 07:27 AM (UTC) by Shadowfyr

Message
Hmm. Wait... In your examples all the names and values where crammed together. Is it more like:
appraisal      3       10

If so then it is obvious why it doesn't work. It only checks for a 'single' space between the name and the digits. You need it to be:

(master dagger|appraisal|smooth talk)\s+\d+\s+\d+

that way it will be the name, followed by 'one or more' spaces, then followed by one or more digits and so on. I didn't even consider that.

There are times that the forum's assumption that it knows better how I intended to format a line than I do is a bit annoying. ;) Imho, programs should never intefere with intentional user formating unless the line is in an actually paragraph and can thus be assumed to be incorrect, but most things don't do this, so I gotta live with it. You should try to remember when posting 'anything' direct from a mud to check the 'forum codes' box and include it in a [code] block. It cuts down on a lot of confusion. ;)

In any case the codes you are most likely to use for matching are:

\w - any thing that can be in a word.
\s - white space (especially spaces themselves, but also tabs)
\S - anything that isn't a white space character.
\d - numbers

You can then use all the other stuff to modify them like:

? - it will match, but doesn't need to be there to do so.
+ - one or more.
{x, y} - x is the minimum number to match, y is the maximum. Doing {x,} is the same as +, but with a minimum that you specify.

My only real gripe is that () is used to define both a 'sub pattern', like we use here, and also the text to return as a wildcard. This is annoying when you have to break a line up into groups, but you don't really care if that part of the matched line is actually passed to a sub.

Anyway. The above is 'most' of what you are likely to need for 99% of stuff you create triggers for, but at some point it is a good idea to read the document that comes with mushclient about regular expressions. Unfortunately it seems to have been written more like a diagram of the syntax, than something intended to help you figure out how to use it. lol Probably got copied directly from some Unix system where everyone was a tech head. ;)
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Fri 21 Feb 2003 09:33 PM (UTC)

Amended on Fri 21 Feb 2003 09:35 PM (UTC) by Nick Gammon

Message
Quote:

I need to highlight a skill on this gain list, but I do not want to highlight the entire line.

My class is a thief. I need to beable to highlight certain skills i need to gain as I level up. I need 'smooth talk 3 58' But I do not want to highlight Spelunking, it does me no good.

I searched for highlighting and it was FAR FAR too complicated, and time consuming for me to setup for each indivual classes and what not.


I gather from all these complex-looking posts that the simple solution is no good?

To simply highlight one word, but not the entire line, set up a trigger that is a regular expression, that just matches that word (or group of words). eg.


Match: (smooth talk|jewelry craft|dual wield)
Regular expression: checked
Change colour to: whatever


This would hightlight those three skills but not others, wherever they are mentioned.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #9 on Sat 22 Feb 2003 04:05 AM (UTC)

Amended on Sat 22 Feb 2003 04:08 AM (UTC) by Shadowfyr

Message
Umm. That is what he is using now, but he 'also' wanted to color the values that followed it. But since he didn't provide an accurate version (i.e. the forum compressed all the extra spaces out of his example) I gave him something that wouldn't work as expected. My last post was the suggested fix and a descriptions of some common regex codes that are likely to be the most useful. ;)

I also provided tools to modify the content of the trigger easilly without having to go into the editor. Had I realized he needed it to match on multiple spaces, the issue would have already been solved. ;)
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #10 on Sat 22 Feb 2003 10:34 AM (UTC)
Message
Ahh... Sucess... that \s+\d+\s+\d+ worked perfectly... Thank you very much...

Now about that code you did for addskill and remskill

I'm taking it that the alias for it to work is something along the lines of:

alias: addskill
script: (The code for that you posted earlier)

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #11 on Sat 22 Feb 2003 06:39 PM (UTC)
Message
Close. The Aliases would be:

Alias: skadd *
Name: SkAdd
Script: AddSkill

Alias: skrem *
Name: SkRem
Script: RemSkill

Alias: sklist
Name: SkList
Script: ListHlt

I figure sk{command} is likely easier to remember and it doesn't matter if the alias you type differs from the script name, however they work just like triggers, so you need that wildcard there for it to do anything. The code itself goes into the script file I think I remember you being told to create in another thread. Unless you turn your scripts, triggers, timers and aliases into plugins, the file you created and specified in the scripting settings is 'always' where code goes.
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #12 on Sun 23 Feb 2003 06:35 AM (UTC)
Message
Ya, I was really tired and I missed the wildcard in the alias. My knowledge of vbscript is really weak, I'm getting errors all over the place, with the code you put up earlier... I don't even have the slightest idea what might be wrong.

It has to do with:
dim tcolor = 1 'Color you want put ehre or something

Its telling me its an expected end of statement/line I believe.

If you would like to help me work out these bugs(meanign you get to do all the work and I get the benefits :P), we could work it out through email.

Thanks a bunch

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #13 on Sun 23 Feb 2003 07:02 AM (UTC)

Amended on Sun 23 Feb 2003 07:03 AM (UTC) by Shadowfyr

Message
Oops.. In both routines it should be:

dim tcolor
tcolor = 1 'Change this to the custom color you use.

VBScript for some idiot reason doesn't allow you to declare a variable and assign it a value on the same line. Hopefully that ends up being the only bug. ;) The code should be fairly straight forward and not likely to have too many bugs. However, since that one slipped through.. lol
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #14 on Sun 23 Feb 2003 09:40 AM (UTC)

Amended on Sun 23 Feb 2003 10:13 AM (UTC) by David B

Message
Fixed some of the obvious problems... a missing end if statement in the last sub

A missing ) in one of the subs.

Get a couple of different errors when trying to use the aliases

Alias: askill *
label: askill
Script: Addskill

Alias: rskill *
Label: rskill
Script: Remskill

Alias: lskill
label: Lskill
Script: ListHlt

Trigger:(knife fighting)\s+\d+\s+\d+
checked: ignore case, regular expression
no change in colour as of yet.
unchecked: all(I have a script to enable and disable the trigger when I type gain list, else it highlights the words even in normal channel use.)
Label: skilllist1

When I type:
askill dancing
I get this:
Error number: -2146828283
Event: Execution of line 39 column 3
Description: Invalid procedure call or argument: 'mid'
Called by: Function/Sub: Addskill called by alias
Reason: processing alias "askill"

When I type
rskill knife fighting
I get this:
Error number: -2146828283
Event: Execution of line 76 column 3
Description: Invalid procedure call or argument: 'mid'
Called by: Function/Sub: Remskill called by alias
Reason: processing alias "rskill"

When I type:
lskill
I get this:
Error number: -2146828283
Event: Execution of line 112 column 3
Description: Invalid procedure call or argument: 'mid'
Called by: Function/Sub: ListHlt called by alias
Reason: processing alias "lskill"


I'm thinking maybe the trigger may be a bit on the flubby side because of the added \s+ because of the spacing. If I'm assuming correctly then the first error cause by line 39

T2 = mid(Temp, p1 + 1, p2 - p1 - 1) 'Get our list of skills.

Is the T2 is the space. and it should be changed to T3... because of the added \s+

I could be wrong on this however.

Same goes for the following 2 errors, its looking for information that is not present at the moment in the trigger because the spot its looking for is a space.

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
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.


68,649 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.