Merge branch 'add_getBounty_to_types_Player' into 'master'

Lua: Add getCrimeLevel() to types.Player

See merge request OpenMW/openmw!3118
This commit is contained in:
psi29a 2023-06-10 08:48:33 +00:00
commit 724d29aa63
5 changed files with 24 additions and 3 deletions

View file

@ -62,7 +62,7 @@ add_openmw_dir (mwlua
luamanagerimp object worldview userdataserializer luaevents engineevents objectvariant luamanagerimp object worldview userdataserializer luaevents engineevents objectvariant
context globalscripts localscripts playerscripts luabindings objectbindings cellbindings context globalscripts localscripts playerscripts luabindings objectbindings cellbindings
camerabindings uibindings inputbindings nearbybindings postprocessingbindings stats debugbindings camerabindings uibindings inputbindings nearbybindings postprocessingbindings stats debugbindings
types/types types/door types/actor types/container types/weapon types/npc types/creature types/activator types/book types/lockpick types/probe types/apparatus types/potion types/ingredient types/misc types/repair types/armor types/light types/static types/clothing types/types types/door types/actor types/container types/weapon types/npc types/creature types/player types/activator types/book types/lockpick types/probe types/apparatus types/potion types/ingredient types/misc types/repair types/armor types/light types/static types/clothing
worker magicbindings worker magicbindings
) )

View file

@ -0,0 +1,16 @@
#include "types.hpp"
#include <apps/openmw/mwmechanics/npcstats.hpp>
#include <apps/openmw/mwworld/class.hpp>
namespace MWLua
{
void addPlayerBindings(sol::table player, const Context& context)
{
player["getCrimeLevel"] = [](const Object& o) -> int {
const MWWorld::Class& cls = o.ptr().getClass();
return cls.getNpcStats(o.ptr()).getBounty();
};
}
}

View file

@ -187,7 +187,7 @@ namespace MWLua
addCreatureBindings(addType(ObjectTypeName::Creature, { ESM::REC_CREA }, ObjectTypeName::Actor), context); addCreatureBindings(addType(ObjectTypeName::Creature, { ESM::REC_CREA }, ObjectTypeName::Actor), context);
addNpcBindings( addNpcBindings(
addType(ObjectTypeName::NPC, { ESM::REC_INTERNAL_PLAYER, ESM::REC_NPC_ }, ObjectTypeName::Actor), context); addType(ObjectTypeName::NPC, { ESM::REC_INTERNAL_PLAYER, ESM::REC_NPC_ }, ObjectTypeName::Actor), context);
addType(ObjectTypeName::Player, { ESM::REC_INTERNAL_PLAYER }, ObjectTypeName::NPC); addPlayerBindings(addType(ObjectTypeName::Player, { ESM::REC_INTERNAL_PLAYER }, ObjectTypeName::NPC), context);
addArmorBindings(addType(ObjectTypeName::Armor, { ESM::REC_ARMO }, ObjectTypeName::Item), context); addArmorBindings(addType(ObjectTypeName::Armor, { ESM::REC_ARMO }, ObjectTypeName::Item), context);
addClothingBindings(addType(ObjectTypeName::Clothing, { ESM::REC_CLOT }, ObjectTypeName::Item), context); addClothingBindings(addType(ObjectTypeName::Clothing, { ESM::REC_CLOT }, ObjectTypeName::Item), context);

View file

@ -50,6 +50,7 @@ namespace MWLua
void addActorBindings(sol::table actor, const Context& context); void addActorBindings(sol::table actor, const Context& context);
void addWeaponBindings(sol::table weapon, const Context& context); void addWeaponBindings(sol::table weapon, const Context& context);
void addNpcBindings(sol::table npc, const Context& context); void addNpcBindings(sol::table npc, const Context& context);
void addPlayerBindings(sol::table player, const Context& context);
void addCreatureBindings(sol::table creature, const Context& context); void addCreatureBindings(sol::table creature, const Context& context);
void addLockpickBindings(sol::table lockpick, const Context& context); void addLockpickBindings(sol::table lockpick, const Context& context);
void addProbeBindings(sol::table probe, const Context& context); void addProbeBindings(sol::table probe, const Context& context);

View file

@ -647,7 +647,11 @@
-- @param openmw.core#GameObject object -- @param openmw.core#GameObject object
-- @return #boolean -- @return #boolean
---
-- Returns the bounty or crime level of the player
-- @function [parent=#Player] getCrimeLevel
-- @param openmw.core#GameObject actor
-- @return #number
--- @{#Armor} functions --- @{#Armor} functions
-- @field [parent=#types] #Armor Armor -- @field [parent=#types] #Armor Armor