So I have quite a dilemma. I have a code that reads a certain msg, for example:
m.content:sub(1,8) == 'Loot of ' then
reads:
01:50 Loot of a starving wolf: a dirty fur, a salad, 2 pancakes, 60 gold
Now I'm trying to make it insert into a table. The problem I have so far is that I can't make it count the type of string and compare it in the table to add its index.
For example:
t = {dirty fur="quantity of msgs that show this",insert a new msg="how many times haves appear}
What I have working so far is:
foreach newmessage m do
m.content:sub(1,8) == 'Loot of ' then
and then I'm just lost. I don't know how to create this table; it should be local, I believe, but the main problem I have with this is that I don't want to print it in pairs, I want to call the values from 1 to #table, in the order they were inserted. That's where my pain starts.
I want something like:
table msgs = {spear='100',something='2', ovni='123'}
so when I get this table (which I still can't make), I can call the same table for another function, that well I want to call table."xmsg" = quantity. I hope someone understands what I'm asking.
function loot()
foreach newmessage m do
if m.type == MSG_INFO and m.content:sub(1,8) == 'Loot of ' then
local content = (m.content:match('Loot of .-: (.+)')):token(nil,', ')
for i,j in ipairs(content) do
return content
end
end
end
end
return msgs of this function :
{"3 gold coins"}
{"3 gold coins"}
{"nothing"}
{"6 gold coins", "a hand axe"}
{"12 gold coins", "a hand axe"}