Fix property extraction from Lua for IntProperty

This commit is contained in:
Alexander Bock
2023-03-10 13:10:14 +01:00
parent 1db7dcf2c3
commit d40c60dd0a
2 changed files with 15 additions and 0 deletions
@@ -44,6 +44,9 @@ public:
int typeLua() const override;
using TemplateProperty<int>::operator=;
private:
int fromLuaConversion(lua_State* state) const override;
};
} // namespace openspace::properties
+12
View File
@@ -41,4 +41,16 @@ int IntProperty::typeLua() const {
return LUA_TNUMBER;
}
int IntProperty::fromLuaConversion(lua_State* state) const {
if (ghoul::lua::hasValue<double>(state)) {
return static_cast<int>(ghoul::lua::value<double>(state));
}
else if (ghoul::lua::hasValue<int>(state)) {
return ghoul::lua::value<int>(state);
}
else {
throw ghoul::RuntimeError(fmt::format("Error extracting value in IntProperty"));
}
}
} // namespace openspace::properties