I'm trying to create a script that catches 2 lines from the world and saves them to a table.
the lines i'm trying to catch are these:
I need to capture the players name, in this case "Tom", and the number he got, in this case "20"
I will do this with 5 players, each going in succession, after which I would like to print back to the world the table containing the players names and their number, sorted by the number.
Here is what I have so far, be gentle I am new to lua in general.
Its bad, and doesn't work obviously, any help would be greatly appreciated.
I realize this doesn't print anything back at this stage, thanks again.
A sample printout would be like:
You say, "Bob 20"
You say, "Frank 17"
You say, "Tom 10"
etc.
the lines i'm trying to catch are these:
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.
I need to capture the players name, in this case "Tom", and the number he got, in this case "20"
I will do this with 5 players, each going in succession, after which I would like to print back to the world the table containing the players names and their number, sorted by the number.
Here is what I have so far, be gentle I am new to lua in general.
require "wait"
wait.make(function () -- coroutine starts here
-- wait for randoms to start
local x = wait.match("The Joker says to", 10)
local players = {}
local num = 1
if not x then
ColourNote("white", "blue", "No randoms withing 10 seconds")
return
end -- if
-- loop until last player randoms
while num < 5 do
for i=1, 5, 1, do
local line, wildcards, styles = wait.match("He blows a cloud of smoke which slowly forms the number *.")
players.name = %1
players.num = %2
end
num = num + 1
end
end) -- end of coroutine
Its bad, and doesn't work obviously, any help would be greatly appreciated.
I realize this doesn't print anything back at this stage, thanks again.
A sample printout would be like:
You say, "Bob 20"
You say, "Frank 17"
You say, "Tom 10"
etc.