Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6914219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:19:08+00:00 2026-05-27T09:19:08+00:00

So I have quite a dilemma. I have a code that reads a certain

  • 0

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"}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:19:09+00:00Added an answer on May 27, 2026 at 9:19 am
    TEST_LOG = [[
    01:50 Loot of a starving wolf: a dirty fur, a large melon, a cactus
    02:20 Loot of a giant: a large melon, an axe
    03:30 You are on fire! Not really, this is just a test message
    04:00 Loot of a starving wolf: a dirty fur, a tooth, a bundle of hair
    04:00 Loot of a starving wolf: a dirty fur, a tooth, an axe
    ]]
    
    ENEMY_LOOT_COUNTS = {}
    LOOT_COUNTS = {}
    
    for line in string.gmatch(TEST_LOG, "([^\n]+)\n") do
        local time, msg = string.match(line, "(%d%d:%d%d) (.+)$")
        if msg and msg:sub(1, 8) == "Loot of " then
            local enemy_name, contents = string.match(msg, "^Loot of a ([^:]+): (.+)$")
            local enemy_t = ENEMY_LOOT_COUNTS[enemy_name]
            if not enemy_t then
                enemy_t = {}
                ENEMY_LOOT_COUNTS[enemy_name] = enemy_t
            end
            local items = {}
            for item_name in string.gmatch(contents, "an? ([^,]+)") do
                items[#items+1] = item_name
                enemy_t[item_name] = (enemy_t[item_name] or 0)+1
                LOOT_COUNTS[item_name] = (LOOT_COUNTS[item_name] or 0)+1
            end
        else
            -- you can handle other messages here if you want
        end
    end
    
    for enemy_name, loot_counts in pairs(ENEMY_LOOT_COUNTS) do
        local s = "Enemy "..enemy_name.." dropped: "
        for item_name, item_count in pairs(loot_counts) do
            s = s..item_count.."x "..item_name..", "
        end
        print(s)
    end
    
    do
        local s = "Overall: "
        for item_name, item_count in pairs(LOOT_COUNTS) do
            s = s..item_count.."x "..item_name..", "
        end
        print(s)
    end
    

    I wanted to write a long answer to accompany this code, but I don’t have the time right now, sorry.
    I’ll do it later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have quite a few lines of code that create objects and using various
I have quite a few RewriteRules in my .htaccess that looks like this RewriteRule
I have quite a few cells that link to other worksheets/books, etc with standard
I have quite big document in html format that generated from Microsoft Word. It
I have quite a lot of C++ legacy code modules from my colleagues, unfortunately
We have quite a few validation methods that need to access repositories / database
I have quite a big table (about 4M of entries) for emails that are
I have quite a few lines of PL/SQL code in Oracle 10g, and we
I have quite silly question: how to send notifications? For example, when I register
I have quite a few simple functions that I had previously kept in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.