Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ Tips and tricks
➜ Determining the healing need of members in my group.
Determining the healing need of members in my group.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Thu 11 Aug 2005 04:11 PM (UTC) |
Message
| I am a healer and now that I'm getting bigger, the groups I join are also growing in size, creating the need for me to monitor the health of more people.
I'd like to make a trigger to report group status and make my job easier. Here is the general format of a group report:
Your group consists of:
----front-----
[50 Pa][4057(4555)h 229(300)m 528( 529)v]&Tyrael
----middle-----
[50 He][1580(1668)h 1229(2059)m 211( 212)v]!Erock
----last-----
[50 Ra][2930(3000)h 215(215)m 455( 457)v]*Kervy
I imagine I could create a trigger that would active on:
[50 *][*(*)h *(*)m *( *)v]*
And what I would like to have it do is calculate the difference between %3 and %2 (%3-%2) and provide a report in the note pad that says something like:
%8 needs %3-%2 hp
But I don't know how to make it do that. Or even if it would work. I
f you look at the example of Kervy (a rare case, but still a possibility) there is an asterisk (*) before his name. If it would make things easier, I shouldn't be seing too many of those at all, so they can be ignored, but everyone has some kind of symbol before thier name, the most common being ! and &. Will that make any difference?
Sorry for the complex posts everyone. I promise my next one will be much less complicated. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Thu 11 Aug 2005 08:33 PM (UTC) |
Message
| It will work. You should really look into regexps for your triggers though. They'll allow you to have triggers with tons of wildcards, and still not get false matches. As well as specify those little symbols infront of peoples names.
What is the 50 for? Shouldn't that be a wildcard as well? What are the possible classes? (I think they're classes: He, Ra, Pa)
Is there really a space infront of your max v: ( 529)v and not m: (300)m? I imagine that will go away when you get a four digit v?
And yes, you've got the right idea about sending "%8 needs (%3 - %2)" Except you'll need to do this instead (so that it subtracts, instead of printing "4555 - 4057":
SendToNotepad "notepad", "%8 needs " & (%3 - %2) & " hp" & VBCrLf
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Reply #2 on Fri 12 Aug 2005 05:01 PM (UTC) |
Message
| I don't know a thing about regexps I'm afraid. I looked at one of the recommended sites on here and I didn't understand what was being explained, though it sounded in arguably useful.
The 50 refers to someone's level. In the MUD I play, you go from 1 - 50 and then there are different ranks within 50 (specified by the symbols !*&% etc.) If someone isn't level 50, then I 1) probably won't be grouping with them and 2) have already worked out a method of keeping tabs on their health. Possible classes include: Ne Co En He Iq Dr Pa Ra Av Ba Ro As.
I am pretty sure about the extra space. For some it may not exist, as they have more than 3 digit v (vitality), but there are still some that do not.
Thank you for confirming some of what I had written codewise. It is nice to know I'm not completely off the mark. :-) | Top |
|
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Reply #3 on Thu 25 Aug 2005 02:24 PM (UTC) |
Message
| So I worked it out pretty well and I've been using it terribly often. My thanks go to all the Mushclient people who helped to make this possible.
But being the greedy sucker I am, I want more. I want to have some of the text in the notepad change color depending on its value. I wouldn't think this is possible, seeing as how notepad is a very basic program, but after doing some hunting, I discovered the NotepadColour function. So here is what I worked out:
(What it triggers on is irrelevant. I want it to change colors if the difference between %3 and %2 is greater than 500)
if " & (%3 - %2) & " > "500" then
NotepadColour "group", "#FF0000", "#FFFFFF"
Else
NotepadColour "group", "#000000", "#FFFFFF"
end if
AppendToNotepad "group", "%6 needs " & (%3 - %2) & " hp" & VBCrLf
So every time the set is lower than 500, I would like it to be black (on white background), but red when higher than 500 (still on white background).
As much as I've checked to make sure that the code is right, it doesn't work. It will still print out black on white background (the default color set).
Have I finally reached too far? | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #4 on Thu 25 Aug 2005 10:19 PM (UTC) |
Message
| Uh, your comparison should simply be:
if (%3 - %2) > 500 then
since the %3 - %2 translates to [max]-[current], which in the other version, we wanted to put between text.
(the first " was the closing quote of the needs bit, we couldnt just substitute, because we needed to do arithmetic, and the & is the append/concatenate symbol, and then the other " was the beginning of the rest of the string, the hp part)
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Reply #5 on Mon 29 Aug 2005 03:53 PM (UTC) Amended on Tue 30 Aug 2005 04:34 PM (UTC) by ErockMahan
|
Message
| Well, I've learned my lesson. I thought it worked exactly as I had intended, but unfortunately it was only close to what I was hoping for.
Here's the deal - I was hoping that the NotepadColour function would only apply to the line under consideration. Meaning, every instance of [*][*(*)h *]* would activate the trigger would paste the difference to a specific notepad. Before doing so, however, it would calculate just how large the difference between %3 and %2 was, and if it was above, say, 500 it would make that line red. So if I were in a group of 5 people, three of which were missing 500 hp, their report would be a different color than the rest.
Instead, what happens, is that the health last person is he who determines the color of the list, regardless of who has how much hp. Is there any function that is line-specific within notepad, or are the colors there uniform no matter what? If possible, I'd prefer some way to make the line a different color based on how large the number is. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #7 on Wed 31 Aug 2005 06:29 PM (UTC) |
Message
| No, notepads are monocolor (it's a text editor, color information isn't text).
There is no way for multiple colors in MC (well, you can use the infobar).
However, there are a bunch of workarounds that have been proposed throughout the ages:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4951
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3946
The first one is a UDP based one from Nick, the second is Poromenos, I believe shadowfyr created one as well, but I didn't see it in my initial search.
If you want to know more about what has been discussed (and also, what Nick may have planned for 'panes' in the future), I suggest you search for "external notepad" or something of the sort. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Reply #8 on Thu 20 Oct 2005 02:03 PM (UTC) |
Message
| Months later I'm back to ask about another little quirk I can't seem to figure out. "if then endif" combinations in the search engine didn't show too much, so I'll just continue what I started.
What I originally wrote would change the color based on the last entry received. What I'm trying to do now is get it to calculate the percentage of hp missing instead of just the number of hp missing (more useful in the end, I suppose) and change colors based on that. To put it simply: When someone is really hurt, the colors will change.
So I worked out a nice llittle way to calculate the percentage, which became the variable "percent" which was then compared to "lowest", and "lowest" would be the lower of the two. After that, I wrote a color changing thing, based upon the "lowest" variable value.
For some reason, my two if-then commands don't like to be in the same script together, but I'm hard pressed to come up with a creative way to seperate them anyway.
Here are my if-then statments:
if lower > percentage Then
World.SetVariable "lowest",percentage
Else
World.SetVariable "lowest",lower
end if
low = World.GetVariable ("lowest")
if low > 50 Then
NotepadColour "group", "#FF0000", "FFFFFF"
if low > 75 Then
NotepadColour "group", "#9900FF", "FFFFFF"
if low > 85 Then
NotepadColour "group", "#00FF00", "FFFFFF"
Else
NotepadColour "group", "000000", "FFFFFF"
end if
But they don't work and I cannot figure out why. It says it needs an "end" instead of "end if", but removing give me a message "end if" needed instead of "end'. Any guess how I can make them work out their differences and live happily in a single script? | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #9 on Thu 20 Oct 2005 09:30 PM (UTC) |
Message
| You need an end if for each if statement.
I suggest you download the VBScript documentation, (Mushclient Forum at the top > list of inbuilt script functions > list of script engines you can download and then theres a link to the help file).
And there is elseif, it's just one word.
The whole thing is this:
If..Then..[ElseIf..][Else..]End If
But you'll find all that (and more) in the script documentation. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #10 on Thu 20 Oct 2005 09:34 PM (UTC) |
Message
| You want to use elseif, this works without syntax errors:
if low > 50 Then
NotepadColour "group", "#FF0000", "FFFFFF"
elseif low > 75 Then
NotepadColour "group", "#9900FF", "FFFFFF"
elseif low > 85 Then
NotepadColour "group", "#00FF00", "FFFFFF"
Else
NotepadColour "group", "000000", "FFFFFF"
end if
However, this idea has a logic problem. Say the "low" variable contains 80. It will pass the first test (80 > 50) and thus execute the first colour change, and the program will never reach the test for (low > 75).
You need to resequence, so you test for the higher values first, and work your way down to the lower ones.
As for colour changes, NotepadColour does indeed change the entire notepad window. Why not try the "info" bar? This is a one-line status bar that can be programmatically changed, including multiple colours and fonts in that line.
http://www.gammon.com.au/scripts/doc.php?general=infobar
Since I presume you simply want an update on the current status of who to heal, a one-line presentation about who most needs it is probably all you need.
Your script can get the party's status, work out who needs healing and how badly, and present them on the info bar, with the most urgent in (say) bold red, followed by others until you run out of room. You should be able to see the first few quite easily.
Also, the regular expression could look like this, which is flexible enough to handle things like grouping with a level 49, and matching the characters before people's names:
^\[\d+ (Ne|Co|En|He|Iq|Dr|Pa|Ra|Av|Ba|Ro|As)\]\[(\d+)\((\d+)\)h (\d+)\((\d+)\)m (\d+)\( (\d+)\)v\](\*|\!|\&)?(.*+)$
In this, the \d+ sequence means "one or more digits", "(Ne|Co|En|He|Iq|Dr|Pa|Ra|Av|Ba|Ro|As)" matches on those exact sequences (this OR that) and "(\*|\!|\&)?" matches * ! or & which may or may not be present.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Reply #11 on Sun 23 Oct 2005 04:25 AM (UTC) |
Message
| Looks great! I'm really enjoying what I am able to do with MUSHclient now that I hadn't ever known before. But now I'm facing some kind of programming problem that I just can't solve. I've really tried, and I can't make head nor tail of what is going wrong.
world.setvariable "percent",%2/%3*100
low = world.getvariable ("lowest") <--this is set to 100 the first time through
perc = world.getvariable ("percent")
if perc < low then
world.setvariable "lowest",perc <--since perc is lower, we make perc the new low.
world.setvariable "lowperson","%5" <--who it applies to
elseif perc < low then
world.setvariable "lowest",low <--unimportant, do nothing command
end if
low = world.getvariable ("lowest") <--just in case the value changed
Any obvious mistakes I'm missing here? | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #12 on Sun 23 Oct 2005 04:50 AM (UTC) |
Message
| You haven't said in what way it is going wrong, but this looks strange:
if perc < low then
' do something
elseif perc < low then
' do something different
end if
But the two ifs are exactly the same!
It's like saying "if it rains today I'll take an umbrella, OTHERWISE if it rains today I won't take an umbrella". |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| ErockMahan
(81 posts) Bio
|
Date
| Reply #13 on Sun 23 Oct 2005 06:21 PM (UTC) |
Message
| Sorry, my code isn't like that. I just copied it incorrectly. To avoid any other typos I may have left behind, here is most of the code (except for where I display what is important, as well as where the variables "lowest" and "damaged" are initially set to extreme values of 0 or 101 (since you can't be hurt less than 0 hp or more than 100% of your health):
world.setvariable "percent",%2/%3*100
world.setvariable "damage",%3-%2
low = world.getvariable ("lowest")
perc = world.getvariable ("percent")
if perc > low then
world.setvariable "lowest",perc
world.setvariable "lowperson","%5"
elseif perc < low then
world.setvariable "lowest",low
end if
low = world.getvariable ("lowest")
dam = world.getvariable ("damage")
maxdam = world.getvariable ("maxdamage")
if dam > maxdam then
world.setvariable "maxdamage",damage
world.setvariable "damaged","%5"
elseif dam < maxdam then
world.setvariable "maxdamage",maxdam
end if | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #14 on Sun 23 Oct 2005 10:32 PM (UTC) |
Message
| I am a bit worried about 2 things. First is your "do nothing" commands. Why have them? If you don't need to do anything, don't, rather than doing a "do nothing" command.
I gather you want to record when the percentage is higher than the highest so far? So why not do this?
if perc > low then
world.setvariable "lowest",perc
world.setvariable "lowperson","%5"
end if
The other problem is that MUSHclient variables are strings, not numbers. So these lines might not work as you expect:
low = world.getvariable ("lowest")
perc = world.getvariable ("percent")
if perc > low then
' do something
It looks OK, but if you have say a perc = 5 and low = 10 then the test will be true, like this:
That is for string compares, the first digit is the most significant, thus "5" is greater than "10".
To fix it, convert them to integers, like this:
low = CInt (world.getvariable ("lowest"))
perc = CInt (world.getvariable ("percent"))
|
- 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.
60,409 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top