Sherlock Holmes
Sherlock Holmes

Reputation: 291

C++ - How to define userdatum with Lua table as member?

I have a userdatum called LuaSettings. This userdatum, except functions, has one member - raw. The raw member is a common Lua table. The usage of this is following:

  1. First, userdatum is pushed on the stack as variable settings

  2. Then Lua file is executed and the userdatum gets modified.

-- LuaSettings:register function modifies the data.raw table
settings:register {
    {
        name = "Fuzz",
        hello = "world"
    },
    {
        name = "Buzz"
        hello = "there"
    }
}

-- User is allowed to do something like this as well:
settings.raw["Fuzz"].hello = ""
  1. After execution is finished, the settings.raw table is used by C++ code.

How to do this? Is this even possible? How do I define the size of this userdatum?

Upvotes: 1

Views: 47

Answers (0)

Related Questions