Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Message
| Hmm. You had a loop of 5 within a loop of 5 there. Let's keep it simple ...
<aliases>
<alias
match="rvr"
enabled="y"
send_to="12"
sequence="100"
>
<send>require "wait"
wait.make(function () -- coroutine starts here
local players = {}
local line, wildcards, styles
-- do 5 players
for i= 1, 5 do
line, wildcards = wait.regexp ("^The Joker says to (.+), ")
players [i] = { name = wildcards [1] }
line, wildcards = wait.match ("He blows a cloud of smoke which slowly forms the number *.")
players [i].num = tonumber (wildcards [1])
print ("Roll", i, "got player", players [i].name, "roll was", players [i].num)
end
-- sort into descending score order
table.sort (players, function (a, b) return a.num > b.num end )
for k, v in ipairs (players) do
Send ("say ", v.name, " ", v.num)
end -- for
end) -- end of coroutine</send>
</alias>
</aliases>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
Test data:
The Joker says to Tom, 'Perhaps this number will bring you luck!'
He blows a cloud of smoke which slowly forms the number 20.
Then, with a wink and a smile, he is gone.
The Joker says to Fred, 'Perhaps this number will bring you luck!'
He blows a cloud of smoke which slowly forms the number 10.
Then, with a wink and a smile, he is gone.
The Joker says to Jill, 'Perhaps this number will bring you luck!'
He blows a cloud of smoke which slowly forms the number 30.
Then, with a wink and a smile, he is gone.
The Joker says to Nadine, 'Perhaps this number will bring you luck!'
He blows a cloud of smoke which slowly forms the number 50.
Then, with a wink and a smile, he is gone.
The Joker says to Nick, 'Perhaps this number will bring you luck!'
He blows a cloud of smoke which slowly forms the number 5.
Then, with a wink and a smile, he is gone.
Output:
Roll 1 got player Tom roll was 20
...
Roll 2 got player Fred roll was 10
...
Roll 3 got player Jill roll was 30
...
Roll 4 got player Nadine roll was 50
...
Roll 5 got player Nick roll was 5
say Nadine 50
say Jill 30
say Tom 20
say Fred 10
say Nick 5
You say 'Nadine 50'
You say 'Jill 30'
You say 'Tom 20'
You say 'Fred 10'
You say 'Nick 5'
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|