1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 13:09:40 +00:00

More object bindings

This commit is contained in:
Petr Mikheev 2021-07-09 00:31:57 +02:00
parent 31e70f2ecc
commit 3771e523f1
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