mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-17 19:20:49 +00:00
Merge branch 'addrepairluabinds' into 'master'
Lua API for Repair records See merge request OpenMW/openmw!1958
This commit is contained in:
commit
f48646b3e6
@ -62,7 +62,7 @@ add_openmw_dir (mwlua
|
||||
luamanagerimp object worldview userdataserializer eventqueue
|
||||
luabindings localscripts playerscripts objectbindings cellbindings asyncbindings settingsbindings
|
||||
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/misc
|
||||
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/misc types/repair
|
||||
)
|
||||
|
||||
add_openmw_dir (mwsound
|
||||
|
35
apps/openmw/mwlua/types/repair.cpp
Normal file
35
apps/openmw/mwlua/types/repair.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "types.hpp"
|
||||
|
||||
#include <components/esm3/loadrepa.hpp>
|
||||
|
||||
#include <apps/openmw/mwworld/esmstore.hpp>
|
||||
|
||||
#include "../luabindings.hpp"
|
||||
|
||||
namespace sol
|
||||
{
|
||||
template <>
|
||||
struct is_automagical<ESM::Repair> : std::false_type {};
|
||||
}
|
||||
|
||||
namespace MWLua
|
||||
{
|
||||
void addRepairBindings(sol::table repair, const Context& context)
|
||||
{
|
||||
const MWWorld::Store<ESM::Repair>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Repair>();
|
||||
repair["record"] = sol::overload(
|
||||
[](const Object& obj) -> const ESM::Repair* { return obj.ptr().get<ESM::Repair>()->mBase; },
|
||||
[store](const std::string& recordId) -> const ESM::Repair* { return store->find(recordId); });
|
||||
sol::usertype<ESM::Repair> record = context.mLua->sol().new_usertype<ESM::Repair>("ESM3_Repair");
|
||||
record[sol::meta_function::to_string] = [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId + "]"; };
|
||||
record["id"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId; });
|
||||
record["name"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mName; });
|
||||
record["model"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mModel; });
|
||||
record["mwscript"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mScript; });
|
||||
record["icon"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mIcon; });
|
||||
record["maxCondition"] = sol::readonly_property([](const ESM::Repair& rec) -> int { return rec.mData.mUses; });
|
||||
record["value"] = sol::readonly_property([](const ESM::Repair& rec) -> int { return rec.mData.mValue; });
|
||||
record["weight"] = sol::readonly_property([](const ESM::Repair& rec) -> float { return rec.mData.mWeight; });
|
||||
record["quality"] = sol::readonly_property([](const ESM::Repair& rec) -> float { return rec.mData.mQuality; });
|
||||
}
|
||||
}
|
@ -170,7 +170,7 @@ namespace MWLua
|
||||
addLockpickBindings(addType(ObjectTypeName::Lockpick, {ESM::REC_LOCK}, ObjectTypeName::Item), context);
|
||||
addProbeBindings(addType(ObjectTypeName::Probe, {ESM::REC_PROB}, ObjectTypeName::Item), context);
|
||||
addApparatusBindings(addType(ObjectTypeName::Apparatus, {ESM::REC_APPA}, ObjectTypeName::Item), context);
|
||||
addType(ObjectTypeName::Repair, {ESM::REC_REPA}, ObjectTypeName::Item);
|
||||
addRepairBindings(addType(ObjectTypeName::Repair, {ESM::REC_REPA}, ObjectTypeName::Item), context);
|
||||
|
||||
addActivatorBindings(addType(ObjectTypeName::Activator, {ESM::REC_ACTI}), context);
|
||||
addContainerBindings(addType(ObjectTypeName::Container, {ESM::REC_CONT}), context);
|
||||
|
@ -35,6 +35,7 @@ namespace MWLua
|
||||
void addLockpickBindings(sol::table lockpick, const Context& context);
|
||||
void addProbeBindings(sol::table probe, const Context& context);
|
||||
void addApparatusBindings(sol::table apparatus, const Context& context);
|
||||
void addRepairBindings(sol::table repair, const Context& context);
|
||||
void addMiscellaneousBindings(sol::table miscellaneous, const Context& context);
|
||||
void addPotionBindings(sol::table potion, const Context& context);
|
||||
}
|
||||
|
@ -885,6 +885,24 @@
|
||||
-- @param openmw.core#GameObject object
|
||||
-- @return #boolean
|
||||
|
||||
---
|
||||
-- Returns the read-only @{#RepairRecord} of a repair tool
|
||||
-- @function [parent=#Repair] record
|
||||
-- @param #any objectOrRecordId
|
||||
-- @return #RepairRecord
|
||||
|
||||
---
|
||||
-- @type RepairRecord
|
||||
-- @field #string id The record ID of the repair tool
|
||||
-- @field #string name The name of the repair tool
|
||||
-- @field #string model VFS path to the model
|
||||
-- @field #string mwscript MWScript on this repair tool (can be empty)
|
||||
-- @field #string icon VFS path to the icon
|
||||
-- @field #number maxCondition The maximum number of uses of this repair tool
|
||||
-- @field #number weight
|
||||
-- @field #number value
|
||||
-- @field #number quality The quality of the repair tool
|
||||
|
||||
--- @{#Activator} functions
|
||||
-- @field [parent=#types] #Activator Activator
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user