1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-20 04:11:32 +00:00

Merge branch 'object_state' into 'master'

Adds a few functions that are needed for camera dehardcoding.

See merge request OpenMW/openmw!1161
This commit is contained in:
psi29a 2021-08-22 14:39:45 +00:00
commit c2d3c9fc01
3 changed files with 57 additions and 1 deletions

View file

@ -25,7 +25,7 @@ namespace MWLua
{
auto* lua = context.mLua;
sol::table api(lua->sol(), sol::create);
api["API_REVISION"] = 4;
api["API_REVISION"] = 5;
api["quit"] = [lua]()
{
std::string traceback = lua->sol()["debug"]["traceback"]().get<std::string>();

View file

@ -158,6 +158,32 @@ namespace MWLua
luaManager->addAction(std::move(action));
};
}
else
{ // Only for local scripts
objectT["isOnGround"] = [](const ObjectT& o)
{
return MWBase::Environment::get().getWorld()->isOnGround(o.ptr());
};
objectT["isSwimming"] = [](const ObjectT& o)
{
return MWBase::Environment::get().getWorld()->isSwimming(o.ptr());
};
objectT["isInWeaponStance"] = [](const ObjectT& o)
{
const MWWorld::Class& cls = o.ptr().getClass();
return cls.isActor() && cls.getCreatureStats(o.ptr()).getDrawState() == MWMechanics::DrawState_Weapon;
};
objectT["isInMagicStance"] = [](const ObjectT& o)
{
const MWWorld::Class& cls = o.ptr().getClass();
return cls.isActor() && cls.getCreatureStats(o.ptr()).getDrawState() == MWMechanics::DrawState_Spell;
};
objectT["getCurrentSpeed"] = [](const ObjectT& o)
{
const MWWorld::Class& cls = o.ptr().getClass();
return cls.getCurrentSpeed(o.ptr());
};
}
}
template <class ObjectT>

View file

@ -127,6 +127,36 @@
-- @param self
-- @return #number
-------------------------------------------------------------------------------
-- Current speed. Can be called only from a local script.
-- @function [parent=#GameObject] getCurrentSpeed
-- @param self
-- @return #number
-------------------------------------------------------------------------------
-- Is the actor standing on ground. Can be called only from a local script.
-- @function [parent=#GameObject] isOnGround
-- @param self
-- @return #boolean
-------------------------------------------------------------------------------
-- Is the actor in water. Can be called only from a local script.
-- @function [parent=#GameObject] isSwimming
-- @param self
-- @return #boolean
-------------------------------------------------------------------------------
-- Is the actor in weapon stance. Can be called only from a local script.
-- @function [parent=#GameObject] isInWeaponStance
-- @param self
-- @return #boolean
-------------------------------------------------------------------------------
-- Is the actor in magic stance. Can be called only from a local script.
-- @function [parent=#GameObject] isInMagicStance
-- @param self
-- @return #boolean
-------------------------------------------------------------------------------
-- Send local event to the object.
-- @function [parent=#GameObject] sendEvent