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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:25:03+00:00 2026-06-09T00:25:03+00:00

What I’m looking for is something like: lua script MY_ARRAY = { 00, 10,

  • 0

What I’m looking for is something like:

lua script

MY_ARRAY = {
00, 10, 54, 32,
12, 31, 55, 43,
34, 65, 76, 34,
53, 78, 34, 93
}

c code

lua_Number array[] = lua_getarray("MY_ARRAY");

Is this possible? Is there anything similar to make dealing with lua tables in C easier.

  • 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-09T00:25:05+00:00Added an answer on June 9, 2026 at 12:25 am

    You can write such function yourself! It shouldn’t be too many lines. But it’s better to use pointers than arrays, because they can point to any number of elements. The interface could be something like this:

    lua_Number *values;
    size_t nvalues;
    values = luaGetNumbers("MY_ARRAY", &nvalues);
    /* the number of values is now nvalues */
    for (int i=0; i<nvalues; i++) {
         /* do something with values[i] */
    }
    free(values);
    

    And the implementation should use the following functions (from http://www.lua.org/manual/5.2/manual.html):

    void lua_getglobal (lua_State *L, const char *name);
    

    Pushes onto the stack the value of the global name.


    void lua_gettable (lua_State *L, int index);
    

    Pushes onto the stack the value t[k], where t is the value at the
    given valid index and k is the value at the top of the stack.

    This function pops the key from the stack putting the resulting value
    in its place). As in Lua, this function may trigger a metamethod for
    the “index” event (see §2.4).


    lua_Number lua_tonumberx (lua_State *L, int index, int *isnum);
    

    Converts the Lua value at the given acceptable index to the C type
    lua_Number (see lua_Number). The Lua value must be a number or a
    string convertible to a number (see §3.4.2); otherwise, lua_tonumberx
    returns 0.

    If isnum is not NULL, its referent is assigned a boolean value that
    indicates whether the operation succeeded.


    void lua_len (lua_State *L, int index);
    

    Returns the “length” of the value at the given acceptable index; it is
    equivalent to the ‘#’ operator in Lua (see §3.4.6). The result is
    pushed on the stack.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I have a jquery bug and I've been looking for hours now, I can't
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,

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.