mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 15:27:13 -04:00
Add nil check
This commit is contained in:
parent
da8949e40a
commit
b0e2265858
@ -502,6 +502,10 @@ namespace MWLua
|
|||||||
};
|
};
|
||||||
objectT["setTransform"] = [context](const GObject& object, const osg::Vec3f& newPos,
|
objectT["setTransform"] = [context](const GObject& object, const osg::Vec3f& newPos,
|
||||||
const sol::object& newRotObj, sol::optional<bool> terrainClampOpt) {
|
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);
|
bool terrainClamp = terrainClampOpt.value_or(true);
|
||||||
MWWorld::Ptr ptr = object.ptr();
|
MWWorld::Ptr ptr = object.ptr();
|
||||||
if (ptr.getCellRef().getCount() == 0 || !ptr.isInCell())
|
if (ptr.getCellRef().getCount() == 0 || !ptr.isInCell())
|
||||||
@ -562,6 +566,10 @@ namespace MWLua
|
|||||||
"SetPositionAction");
|
"SetPositionAction");
|
||||||
};
|
};
|
||||||
objectT["setRotation"] = [context](const GObject& object, const sol::object& newRotObj) {
|
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();
|
MWWorld::Ptr ptr = object.ptr();
|
||||||
if (ptr.getCellRef().getCount() == 0 || !ptr.isInCell())
|
if (ptr.getCellRef().getCount() == 0 || !ptr.isInCell())
|
||||||
throw std::runtime_error("Object is either removed or in the process of teleporting");
|
throw std::runtime_error("Object is either removed or in the process of teleporting");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user