Jump to content

HELP with table


Recommended Posts

local narrows =
    {
        {8843, 3736.6, -1569, 150.8, 349, 0, 60},
        {8843, 3736.7, -1569, 170.6, 348, 180, 60}
}

function just_a_function()
    createObject(narrows[1])
    createObject(narrows[2])
end

// just_a_function() is called in other function

 

It says 'createObject' [expected number at argument 1, got table]

Edited by Hiding
Link to post

You need to specify every element of every row in the table in createObject.

Just like this:

createObject(narrows[1][1], narrows[1][2], narrows[1][3], narrows[1][4], narrows[1][5], narrows[1][6], narrows[1][7])

 

Edited by SpecT
  • Like 1
Link to post
  • Moderators

Hi.

You have to unpack values first, because now you pass only a table to createObject.

function just_a_function()
    -- get the values from table
    local model, x, y, z, rx, ry, rz = narrows[1][1], narrows[1][2], narrows[1][3], narrows[1][4], narrows[1][5], narrows[1][6], narrows[1][7]
    createObject(model, x, y, z, rx, ry, rz)

    -- or you can use 'unpack'
    local model, x, y, z, rx, ry, rz = unpack(narrows[2])
    createObject(model, x, y, z, rx, ry, rz)
end

 

Edited by Patrick
  • Like 1
Link to post

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...