mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-05 10:59:47 -05:00
Fix property extraction from Lua for IntProperty
This commit is contained in:
@@ -44,6 +44,9 @@ public:
|
||||
int typeLua() const override;
|
||||
|
||||
using TemplateProperty<int>::operator=;
|
||||
|
||||
private:
|
||||
int fromLuaConversion(lua_State* state) const override;
|
||||
};
|
||||
|
||||
} // namespace openspace::properties
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user