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:
parent
31e70f2ecc
commit
3771e523f1
3 changed files with 57 additions and 1 deletions
|
@ -25,7 +25,7 @@ namespace MWLua
|
||||||
{
|
{
|
||||||
auto* lua = context.mLua;
|
auto* lua = context.mLua;
|
||||||
sol::table api(lua->sol(), sol::create);
|
sol::table api(lua->sol(), sol::create);
|
||||||
api["API_REVISION"] = 4;
|
api["API_REVISION"] = 5;
|
||||||
api["quit"] = [lua]()
|
api["quit"] = [lua]()
|
||||||
{
|
{
|
||||||
std::string traceback = lua->sol()["debug"]["traceback"]().get<std::string>();
|
std::string traceback = lua->sol()["debug"]["traceback"]().get<std::string>();
|
||||||
|
|
|
@ -158,6 +158,32 @@ namespace MWLua
|
||||||
luaManager->addAction(std::move(action));
|
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>
|
template <class ObjectT>
|
||||||
|
|
|
@ -127,6 +127,36 @@
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return #number
|
-- @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.
|
-- Send local event to the object.
|
||||||
-- @function [parent=#GameObject] sendEvent
|
-- @function [parent=#GameObject] sendEvent
|
||||||
|
|
Loading…
Reference in a new issue