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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:09:38+00:00 2026-06-07T20:09:38+00:00

Hello I am really stumped with this seemingly simple task. I can access the

  • 0

Hello I am really stumped with this seemingly simple task.
I can access the properties of a table passed to a function in C, but cannot access the members of any subtable i create in it.

Basically I want to simply be able to extract the strings from the properties table so i can create say a “wheel” according to the users expectations.

Here is what I have so far (tried so much my brain is fried)

Lua Side:

--Function
createSomething( "wheel", { canInflate = true, properties = { "large", "full" } } )

C Side:

//I can retrieve any value easily within that table, but cannot seem to extract the table
//Within it named "properties", i can access the table, but cannot extract the strings     inside

if( lua_istable(L, 2) ) {
    lua_getfield(L, 2, "canInflate");  // Let's extract the value for the key 'someKey'. Pushes the value on the top of the stack
    static int canInflate = lua_toboolean(L, -1); // get the value of bool now at the top of stack (index: -1)

    //printf("can inflate is %d\n", canInflate);
    //lua_pop(L, 1); // pop the value now that we are done with it
}


//try to get the properties table
if ( lua_istable(L, 2) ) {
    lua_getfield(L, 2, "properties");

    const char *str = lua_tostring(L, -1);

    printf( "properties 1 = %s\n", str); // NULL

    lua_pop(L, 2);
}

Any help on this would be greatly appreciated

  • 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-06-07T20:09:39+00:00Added an answer on June 7, 2026 at 8:09 pm

    The problem you’re having is with how you specify tables in Lua: the following 3 statements have exactly the same result:

    t = { 'full','large'}
    t = { [1] = 'full', [2] = 'large'}
    t={};t[1]='full';t[2]='large'
    

    What you want is to use the strings as keys instead of values (as is done in your code and the above samples):

    t={full=true,large=true}
    -- or 
    t={}; t.full=true; t.large=true
    

    If you use the strings as keys your C code should work.

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

Sidebar

Related Questions

Ok really easy I know but not for me... I can not figure this
Hello I want to create a simple blog where users can post comments, but
Hello this might be really silly question but I am trying to make markers
I am really stumped on this one. I have a simple python wrapper which
I'm getting really fustrated with this... With this simple xml: <?xml version='1.0'?> <root> <data>hello</data>
Can anyone point me to a really simple hello world type of application that
Hello once again stackoverflow folks, this is really hard and it's been torturing my
I have really simple problem in my PHP script. There is a function defined
Hello dear users of the stackoverflow! I really like the search form on this
I'm relatively(read: stupid newbie) familiar with disassembly but this bit stumped me: I have

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.