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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ "Who here"-list

"Who here"-list

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


Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Fri 15 Jul 2005 04:45 PM (UTC)
Message
When sending the command "who here" on the MUD I'm playing, I get a list of players in the room. It looks something like: "Player1, Player2, Player3" or just "Player1". What I want to do is replace this with: "(1) Player1 (2) Player2 (3) Player3", for example. But my trigger doesn't seem to be sending all the parameters it should, or atleast that's what I believe is the problem.

I have:
<trigger name="whohere" enabled="n" keep_evaluating="y" match="^(\w+)(?:\, (\w+))*" regexp="y" omit_from_output="y" omit_from_log="y" send_to="12" script="whohere"></trigger>


And the whohere() function:
function whohere(name, line, wildcards)
    EnableTrigger("whohere", false)
    for k in wildcards do
        ColourTell("silver", "", "(", "lightskyblue", "", tostring(k), "silver", "", ")", "royalblue", "", " " .. tostring(wildcards[k]) .. " ")
    end
    ColourNote("", "", "")
end


When I checked it with "Tyfor, Jherok, Nicanee", all I got was:
1 = Tyfor
2 = Jherok
0 = Tyfor, Jherok, Nicanee


Anyone have any idea why it's behaving like this? Doesn't make much sense to me.

Simplicity is Divine | http://nogfx.org/
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #1 on Sun 17 Jul 2005 11:10 AM (UTC)
Message
I have learned that you can't create an open-ended set of wildcards just by putting + or * after a pattern. You will have to match the pattern as a single wildcard and then split it yourself, I think.
Top

Posted by tobiassjosten   Sweden  (79 posts)  Bio
Date Reply #2 on Sun 17 Jul 2005 06:48 PM (UTC)

Amended on Sun 17 Jul 2005 08:22 PM (UTC) by tobiassjosten

Message
I thought it had something to do with the "greedy-mode", but tests showed me it didn't matter.

Any idea on how I could split the line up into an table with each name? Or how should I do this? Looping a table with the names comes first to mind to me.

Edit: Nevermind, I got it to work.
function whohere(name, line)
    EnableTrigger("whohere", false)
    local num = 0
    for w in string.gfind(line, "%w+") do
        num = num + 1
        ColourTell("silver", "", "(", "goldenrod", "", tostring(num), "silver", "", ") " .. w .. " ")
        tgt[num] = w
    end
    if num > 0 then
        ColourNote("", "", "")
    end
end

Simplicity is Divine | http://nogfx.org/
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.


14,483 views.

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.