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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:22:18+00:00 2026-05-27T08:22:18+00:00

I want to enable Lua-Scripting (Lua 5.1) in my Delphi application. For this purpose

  • 0

I want to enable Lua-Scripting (Lua 5.1) in my Delphi application. For this purpose I use the header Files of Thomas Lavergne.

Now I try to register a userdata type following this example: http://www.lua.org/pil/28.2.html

At the “new array function” it uses the command *luaL_getmetatable*.

static int newarray (lua_State *L) {
  int n = luaL_checkint(L, 1);
  size_t nbytes = sizeof(NumArray) + (n - 1)*sizeof(double);
  NumArray *a = (NumArray *)lua_newuserdata(L, nbytes);

  luaL_getmetatable(L, "LuaBook.array");
  lua_setmetatable(L, -2);

  a->size = n;
  return 1;  /* new userdatum is already on the stack */
}

Unfortunately the *luaL_getmetatable* Function is marked al old at my header File and commented out. I tried to activate it again but as expected I will get an error because the dll entrancepoint couldn’t be found.

This is the Delphi-translation of that example (using another non array datatype)

Type
  tMyType = tWhatever;
  pMyType = ^tMyType;
{...}

Function newusertype(aState : pLua_State) : LongInt; cdecl;
  Var
    NewData : pMyType;
  Begin
    Result := 0;
    NewData := lua_newuserdata(aState, SizeOf(tMyType ));
    NewData^ := GetInitValue;
    luaL_getMetaTable(aState, 'myexcample.mytype'); // Error/unknown function
    lua_setmetatable(aState, -2);
    Result := 1;
  End;

Now I’m looking for an replacement of luaL_getMetaTable. I haven’t found any information about one. In fact I haven’t found any information that luaL_getMetaTable is outdated but it seems to be :(.

  • 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-27T08:22:19+00:00Added an answer on May 27, 2026 at 8:22 am

    use lua_newmetatable(aState, 'myexample.mytype'). The thing is (if you only want to continue if the metatable already exists) you’ll need to evaluate whether it returns a 0! If it returns 0, then it’s wanting to create the metatable… in which case you can lua_pop(aState, 1).

    Just remember that lua_newmetatable is a function returning an Integer (which in reality should be a Boolean).

    Otherwise you can wait a few weeks for me to release Lua4Delphi version 2, which makes all of this super easy (and the Professional version actually automates the registration of Delphi Types and Instances with Lua)

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

Sidebar

Related Questions

I want to enable the users of my website to download the files from
I want to enable drag-and-drop behaviour on my Web application. I have an image
I want to Enable the Mouse moves and clicks Using c# windows application. How
I want to enable drag and drop from our windows forms based application to
I want to enable 'Apply' dialog button when content of some textboxes in this
I want globally enable whitespace-mode. I have tried this in my .emacs: (require 'whitespace)
I want to enable/disable clipboard in an edittext. How can I do this?
I want to enable cross site scripting for some sites. Specifically, I want to
I want to enable file download in my MVC application, without simply using a
I want to enable an user to be able to communicate with other users

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.