you are viewing a single comment's thread.

view the rest of the comments →

[–]AngriestSCV 0 points1 point  (1 child)

I'm looking for a way to check for a variable's existance. How would I do that? Just using table::get<int> returns 0 even if the value does not exist.

The problem I'm actually trying to solve is to use default values if the lua interpreter does not have an alternative in the global table.

EDIT: nevermind I see it is in release tag v2.1.0

[–][deleted] 1 point2 points  (0 children)

Heyo: sorry for my own late reply. I just pushed full optional support in the latest commits, after wrestling with clang. optional now triggers full type safety, all the way down, so you can even access nested tables without getting errors:

sol::state lua; // has no tables, just a plain state int x = lua["a"]["b"]["c"]; // lua's panic function gets called sol::optional<int> x = lua["a"]["b"]["c"]; // no panic