1

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?

Sherlock Holmes
  • 191
  • 1
  • 8
  • 1
    Why do you need userdata here? Let `settings` be usual Lua table, you can store it in the registry (and store its ref in some `int` C variable). – Egor Skriptunoff Jan 06 '21 at 23:15

0 Answers0