sol2
sol2 copied to clipboard
Question: How to create getters and setters for sub-tables
Thanks for this great library!
Sorry if the question doesn't make any sense, I just don't know how to explain it in a sentence. Let's say I have a table table with the sub-tables ui and opt. I want to have getter/setter for members of opt e.g: table.opt.terminal = "value" and print(table.opt.terminal). I have defined the sol::state in a class and all the lua API definitions should reside in this class.
How can I get the following behavior
class Table {
public:
void LuaAPI() noexcept;
private:
sol::state lua;
};
void Table::LuaAPI() noexcept {
sol::table table = lua.create_named["table"]
table.new_usertype<Table>("table");
table["opt"] = this;
table["opt"]["terminal"] = sol::property(&Table::Getter, &Table::Setter);
table["ui"]... // UI table with members
}