Jump to content

Array -> Question


Recommended Posts

Hello is there everyone way to add new block with table.insert or etc.

local Ankety = {
        [0] = {
            ["nazev"] = "ABC",
            ["obsah"] = " Yeah your car",
            ["hlasoval"] = 1,
            ["Ano"] = 24,
            ["Ne"] = 20,
        },
        [1] = {
            ["nazev"] = "ASC",
            ["obsah"] = ' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer rutrum quam mauris, sed \n commodo odio auctor malesuada. Sed lacus lacus, \n semper a nisi nec, condimentum tincidunt sem. \n Aliquam et odio nulla.',
            ["hlasoval"] = 0,
            ["Ano"] = 31,
            ["Ne"] = 50,
        }
    }

and i need with table.insert or anything make that:

local Ankety = {
        [0] = {
            ["nazev"] = "ABC",
            ["obsah"] = " :O your :O",
            ["hlasoval"] = 1,
            ["Ano"] = 24,
            ["Ne"] = 20,
        },
        [1] = {
            ["nazev"] = "ASC",
            ["obsah"] = ' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer rutrum quam mauris, sed \n commodo odio auctor malesuada. Sed lacus lacus, \n semper a nisi nec, condimentum tincidunt sem. \n Aliquam et odio nulla.',
            ["hlasoval"] = 0,
            ["Ano"] = 31,
            ["Ne"] = 50,
        },
        [2] = {
            ["nazev"] = "And",
            ["obsah"] = ' Yeah ipsum dolor sit amet, consectetur adipiscing elit. Integer rutrum quam mauris, sed \n commodo odio auctor malesuada. Sed lacus lacus, \n semper a nisi nec, condimentum tincidunt sem. \n Aliquam et odio nulla.',
            ["hlasoval"] = 0,
            ["Ano"] = 10,
            ["Ne"] = 15,
        }
    }

Thank for help.

Link to comment

Well yeah.. it's quite simple really. Just create a separate table with the values of the nested tables and insert it.. there's not much to it.

local poll = {
            ["nazev"] = "And",
            ["obsah"] = ' Yeah ipsum dolor sit amet, consectetur adipiscing elit. Integer rutrum quam mauris, sed \n commodo odio auctor malesuada. Sed lacus lacus, \n semper a nisi nec, condimentum tincidunt sem. \n Aliquam et odio nulla.',
            ["hlasoval"] = 0,
            ["Ano"] = 10,
            ["Ne"] = 15,
        }

Ankety:insert(poll)

 

Edited by MIKI785
  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...