[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  "Who here"-list
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

"Who here"-list

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


Posted by tobiassjosten   Sweden  (79 posts)  [Biography] 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/
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] 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.
[Go to top] top

Posted by tobiassjosten   Sweden  (79 posts)  [Biography] 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/
[Go to top] 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.


4,046 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]