Add nil check

This commit is contained in:
SkyHasACat 2025-08-01 08:57:44 -07:00
parent da8949e40a
commit b0e2265858

View File

@ -502,6 +502,10 @@ namespace MWLua
};
objectT["setTransform"] = [context](const GObject& object, const osg::Vec3f& newPos,
const sol::object& newRotObj, sol::optional<bool> terrainClampOpt) {
if (newRotObj == sol::nil)
{
throw std::runtime_error("setTransform requires a non-nil rotation argument");
}
bool terrainClamp = terrainClampOpt.value_or(true);
MWWorld::Ptr ptr = object.ptr();
if (ptr.getCellRef().getCount() == 0 || !ptr.isInCell())
@ -562,6 +566,10 @@ namespace MWLua
"SetPositionAction");
};
objectT["setRotation"] = [context](const GObject& object, const sol::object& newRotObj) {
if (newRotObj == sol::nil)
{
throw std::runtime_error("setTransform requires a non-nil rotation argument");
}
MWWorld::Ptr ptr = object.ptr();
if (ptr.getCellRef().getCount() == 0 || !ptr.isInCell())
throw std::runtime_error("Object is either removed or in the process of teleporting");