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 6153163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:02:50+00:00 2026-05-23T20:02:50+00:00

Need to create some table so I can get an info from it in

  • 0

Need to create some table so I can get an info from it in this way:

table[attacker][id]

And if I’ll use

print(table[attacker][id])

It should print the value.

Tried many ways, but haven’t found any good …

I guess it should be something like this…

table.insert(table, attacker, [id] = value)

^ This does not work.

Can someone help me?


Edit

Well, when I try it this way:

x = {}
function xxx()
    if not x[attacker][cid] then
        x[attacker][cid] = value
    else
        x[attacker][cid] = x[attacker][cid] + value
    end
    print(x[attacker][cid])
end

I get an error saying:

attempt to index field ‘?’ (a nil value)

  • 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-23T20:02:52+00:00Added an answer on May 23, 2026 at 8:02 pm

    You need the curly braces to create the inner table:

    table.insert(my_table, attacker, {[id]=value})
    

    or

    -- the advantage of this is that it works even if 'attacker' isn't a number
    my_table[attacker] = {[id]=value}
    

    a = 1
    b = 2
    c = 3
    d = {}
    table.insert(d, a, {[b]=c})
    print(d[a][b]) -- prints '3'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create an SQL query to insert some data into a table
I need some help to create pages with different views. Don't get me wrong,
Hoping I can get some architectural advice on this. I have been given the
This thing is really bothering me. How can I get my dropdown list from
I need to create some windows service which will execute every N period of
When I am testing my DAL I need to create some database entities before
In a PHP project I'm working on we need to create some DAL extensions
For a Website I'm developing, I will need to create some graphics. I haven't
I have several web services I need to create for them some testing mechanism
Hi I need to create a module in drupal to display some data, not

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.