MrTabby Newbie
Joined: 14 Jan 2002 Posts: 4 Location: United Kingdom
|
Posted: Mon Jan 14, 2002 5:39 pm
An alias/function for coloured status messages? |
Yay! A second newbie post.
While I have some skill in programming, I still haven't completely understood the whole zMud parsing mode concept, and I suspect this is where I am having my problems.
I am trying to write a set of triggers and so forth to take pertinent information from the main (and decidedly spammy) main window, and put it into others which I have arranged around. The problem is writing the function or alias (Which, incidentally, I'm still not sure which would be best suited for the task) to take a variable and a string, and send it to the correct window.
currently, I have the following alias: <msgWin>
---
pretty_output=%-2
#FORALL @col_list {pretty_output=%replace( @pretty_output, %word( %i, 1, "=") , %quote( %ansi( %word( %i, 2, "="))))}
#IF (%ismember( %1, %names)) {:%1:#SHOW { "<"<@pretty_output>">"}} {:mainwin:#SAY "Message sent to nonexistent window" %1}
---
which is called from triggers using:
#EXEC msgWin <mywindowname> "This is a message" // for standard messages, but also allows for
#EXEC msgWin <mywindowname> "!REDThis !BLUEis !WHITEa Pretty Message"
where pretty_output is just a temp variable, and col_list is a string list of the format !BLUE=137 to allow me to change if I want it bold or not, etc
So far, this works, but doesn't do exactly what I want, especially when trying to use special characters such as "[" or "]" in the
message to be displayed. Quoting them with %quote("]") or "~]" doesn't seem to work either, or at least not if I want a matched pair. I am assuming that they are trying to be parsed at some point, and I haven't yet figured out where this is happening.
The same goes for the %replace() function in the msgWin alias, since otherwise the ;'s of the ansi control codes get interpreted as line seperators, and I end up with a load of control sequences and bits of message being sent to the mud.
Eventually, I want to get together a set of useful [functions|aliases] which I can then use to sort all this info to where it should be.
An example of this would be the <TstampMsg> alias, which is supposed to take 2 args again, and send a message of <Timestamp>: %1 to window %1
eg:
tstampmsg "group_status" "!REDYour shield has broken" would send the message "[19:35:16]: Your shield has broken" (but with relevant colour, which I haven't done in this post :)
If someone would be able to explain the use of functions (which are just variables of "script type" or not?) and aliases, and when each should be used, preferably with a little sample code, it would be most appreciated.
I have seen http://www.zuggsoft.com/zmud/prog.htm and it hasn't really helped.
Thanks.
--
MrTabby |
|