mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Use common function to add record binding
This commit is contained in:
parent
33a59a9342
commit
ca9c55ac26
@ -23,13 +23,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Activator>* store
|
addRecordFunctionBinding<ESM::Activator>(activator);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Activator>();
|
|
||||||
activator["record"] = sol::overload(
|
|
||||||
[](const Object& obj) -> const ESM::Activator* { return obj.ptr().get<ESM::Activator>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Activator* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Activator> record = context.mLua->sol().new_usertype<ESM::Activator>("ESM3_Activator");
|
sol::usertype<ESM::Activator> record = context.mLua->sol().new_usertype<ESM::Activator>("ESM3_Activator");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Activator& rec) { return "ESM3_Activator[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Activator& rec) { return "ESM3_Activator[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -30,13 +30,8 @@ namespace MWLua
|
|||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Apparatus>* store
|
addRecordFunctionBinding<ESM::Apparatus>(apparatus);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Apparatus>();
|
|
||||||
apparatus["record"] = sol::overload(
|
|
||||||
[](const Object& obj) -> const ESM::Apparatus* { return obj.ptr().get<ESM::Apparatus>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Apparatus* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Apparatus> record = context.mLua->sol().new_usertype<ESM::Apparatus>("ESM3_Apparatus");
|
sol::usertype<ESM::Apparatus> record = context.mLua->sol().new_usertype<ESM::Apparatus>("ESM3_Apparatus");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Apparatus& rec) { return "ESM3_Apparatus[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Apparatus& rec) { return "ESM3_Apparatus[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -37,12 +37,8 @@ namespace MWLua
|
|||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Armor>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Armor>();
|
addRecordFunctionBinding<ESM::Armor>(armor);
|
||||||
armor["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::Armor* { return obj.ptr().get<ESM::Armor>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Armor* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Armor> record = context.mLua->sol().new_usertype<ESM::Armor>("ESM3_Armor");
|
sol::usertype<ESM::Armor> record = context.mLua->sol().new_usertype<ESM::Armor>("ESM3_Armor");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Armor& rec) -> std::string { return "ESM3_Armor[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Armor& rec) -> std::string { return "ESM3_Armor[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -32,12 +32,8 @@ namespace MWLua
|
|||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Book>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Book>();
|
addRecordFunctionBinding<ESM::Book>(book);
|
||||||
book["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::Book* { return obj.ptr().get<ESM::Book>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Book* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Book> record = context.mLua->sol().new_usertype<ESM::Book>("ESM3_Book");
|
sol::usertype<ESM::Book> record = context.mLua->sol().new_usertype<ESM::Book>("ESM3_Book");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Book& rec) { return "ESM3_Book[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Book& rec) { return "ESM3_Book[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -36,13 +36,8 @@ namespace MWLua
|
|||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Clothing>* store
|
addRecordFunctionBinding<ESM::Clothing>(clothing);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Clothing>();
|
|
||||||
clothing["record"] = sol::overload(
|
|
||||||
[](const Object& obj) -> const ESM::Clothing* { return obj.ptr().get<ESM::Clothing>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Clothing* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Clothing> record = context.mLua->sol().new_usertype<ESM::Clothing>("ESM3_Clothing");
|
sol::usertype<ESM::Clothing> record = context.mLua->sol().new_usertype<ESM::Clothing>("ESM3_Clothing");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Clothing& rec) -> std::string { return "ESM3_Clothing[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Clothing& rec) -> std::string { return "ESM3_Clothing[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -48,13 +48,8 @@ namespace MWLua
|
|||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Container>* store
|
addRecordFunctionBinding<ESM::Container>(container);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Container>();
|
|
||||||
container["record"] = sol::overload(
|
|
||||||
[](const Object& obj) -> const ESM::Container* { return obj.ptr().get<ESM::Container>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Container* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Container> record = context.mLua->sol().new_usertype<ESM::Container>("ESM3_Container");
|
sol::usertype<ESM::Container> record = context.mLua->sol().new_usertype<ESM::Container>("ESM3_Container");
|
||||||
record[sol::meta_function::to_string] = [](const ESM::Container& rec) -> std::string {
|
record[sol::meta_function::to_string] = [](const ESM::Container& rec) -> std::string {
|
||||||
return "ESM3_Container[" + rec.mId.toDebugString() + "]";
|
return "ESM3_Container[" + rec.mId.toDebugString() + "]";
|
||||||
|
@ -23,13 +23,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Creature>* store
|
addRecordFunctionBinding<ESM::Creature>(creature);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>();
|
|
||||||
creature["record"] = sol::overload(
|
|
||||||
[](const Object& obj) -> const ESM::Creature* { return obj.ptr().get<ESM::Creature>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Creature* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Creature> record = context.mLua->sol().new_usertype<ESM::Creature>("ESM3_Creature");
|
sol::usertype<ESM::Creature> record = context.mLua->sol().new_usertype<ESM::Creature>("ESM3_Creature");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -44,12 +44,8 @@ namespace MWLua
|
|||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Door>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Door>();
|
addRecordFunctionBinding<ESM::Door>(door);
|
||||||
door["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::Door* { return obj.ptr().get<ESM::Door>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Door* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Door> record = context.mLua->sol().new_usertype<ESM::Door>("ESM3_Door");
|
sol::usertype<ESM::Door> record = context.mLua->sol().new_usertype<ESM::Door>("ESM3_Door");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Door& rec) -> std::string { return "ESM3_Door[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Door& rec) -> std::string { return "ESM3_Door[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -24,13 +24,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Ingredient>* store
|
addRecordFunctionBinding<ESM::Ingredient>(ingredient);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>();
|
|
||||||
ingredient["record"] = sol::overload(
|
|
||||||
[](const Object& obj) -> const ESM::Ingredient* { return obj.ptr().get<ESM::Ingredient>()->mBase; },
|
|
||||||
[store](const std::string& recordID) -> const ESM::Ingredient* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordID));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Ingredient> record = context.mLua->sol().new_usertype<ESM::Ingredient>(("ESM3_Ingredient"));
|
sol::usertype<ESM::Ingredient> record = context.mLua->sol().new_usertype<ESM::Ingredient>(("ESM3_Ingredient"));
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Ingredient& rec) { return "ESM3_Ingredient[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Ingredient& rec) { return "ESM3_Ingredient[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -23,12 +23,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Light>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Light>();
|
addRecordFunctionBinding<ESM::Light>(light);
|
||||||
light["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::Light* { return obj.ptr().get<ESM::Light>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Light* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Light> record = context.mLua->sol().new_usertype<ESM::Light>("ESM3_Light");
|
sol::usertype<ESM::Light> record = context.mLua->sol().new_usertype<ESM::Light>("ESM3_Light");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Light& rec) -> std::string { return "ESM3_Light[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Light& rec) -> std::string { return "ESM3_Light[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -23,13 +23,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Lockpick>* store
|
addRecordFunctionBinding<ESM::Lockpick>(lockpick);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Lockpick>();
|
|
||||||
lockpick["record"] = sol::overload(
|
|
||||||
[](const Object& obj) -> const ESM::Lockpick* { return obj.ptr().get<ESM::Lockpick>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Lockpick* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Lockpick> record = context.mLua->sol().new_usertype<ESM::Lockpick>("ESM3_Lockpick");
|
sol::usertype<ESM::Lockpick> record = context.mLua->sol().new_usertype<ESM::Lockpick>("ESM3_Lockpick");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Lockpick& rec) { return "ESM3_Lockpick[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Lockpick& rec) { return "ESM3_Lockpick[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -23,13 +23,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Miscellaneous>* store
|
addRecordFunctionBinding<ESM::Miscellaneous>(miscellaneous);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Miscellaneous>();
|
|
||||||
miscellaneous["record"] = sol::overload(
|
|
||||||
[](const Object& obj) -> const ESM::Miscellaneous* { return obj.ptr().get<ESM::Miscellaneous>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Miscellaneous* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Miscellaneous> record
|
sol::usertype<ESM::Miscellaneous> record
|
||||||
= context.mLua->sol().new_usertype<ESM::Miscellaneous>("ESM3_Miscellaneous");
|
= context.mLua->sol().new_usertype<ESM::Miscellaneous>("ESM3_Miscellaneous");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
|
@ -25,12 +25,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
addNpcStatsBindings(npc, context);
|
addNpcStatsBindings(npc, context);
|
||||||
|
|
||||||
const MWWorld::Store<ESM::NPC>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::NPC>();
|
addRecordFunctionBinding<ESM::NPC>(npc);
|
||||||
npc["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::NPC* { return obj.ptr().get<ESM::NPC>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::NPC* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::NPC> record = context.mLua->sol().new_usertype<ESM::NPC>("ESM3_NPC");
|
sol::usertype<ESM::NPC> record = context.mLua->sol().new_usertype<ESM::NPC>("ESM3_NPC");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::NPC& rec) { return "ESM3_NPC[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::NPC& rec) { return "ESM3_NPC[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -21,13 +21,7 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
void addPotionBindings(sol::table potion, const Context& context)
|
void addPotionBindings(sol::table potion, const Context& context)
|
||||||
{
|
{
|
||||||
const MWWorld::Store<ESM::Potion>* store
|
addRecordFunctionBinding<ESM::Potion>(potion);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>();
|
|
||||||
potion["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::Potion* { return obj.ptr().get<ESM::Potion>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Potion* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
sol::usertype<ESM::Potion> record = context.mLua->sol().new_usertype<ESM::Potion>("ESM3_Potion");
|
sol::usertype<ESM::Potion> record = context.mLua->sol().new_usertype<ESM::Potion>("ESM3_Potion");
|
||||||
|
@ -23,12 +23,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Probe>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Probe>();
|
addRecordFunctionBinding<ESM::Probe>(probe);
|
||||||
probe["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::Probe* { return obj.ptr().get<ESM::Probe>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Probe* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Probe> record = context.mLua->sol().new_usertype<ESM::Probe>("ESM3_Probe");
|
sol::usertype<ESM::Probe> record = context.mLua->sol().new_usertype<ESM::Probe>("ESM3_Probe");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -23,13 +23,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Repair>* store
|
addRecordFunctionBinding<ESM::Repair>(repair);
|
||||||
= &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(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Repair> record = context.mLua->sol().new_usertype<ESM::Repair>("ESM3_Repair");
|
sol::usertype<ESM::Repair> record = context.mLua->sol().new_usertype<ESM::Repair>("ESM3_Repair");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -23,13 +23,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Static>* store
|
addRecordFunctionBinding<ESM::Static>(stat);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>();
|
|
||||||
stat["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::Static* { return obj.ptr().get<ESM::Static>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Static* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Static> record = context.mLua->sol().new_usertype<ESM::Static>("ESM3_Static");
|
sol::usertype<ESM::Static> record = context.mLua->sol().new_usertype<ESM::Static>("ESM3_Static");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
#include <components/esm/defs.hpp>
|
#include <components/esm/defs.hpp>
|
||||||
|
|
||||||
|
#include "apps/openmw/mwbase/environment.hpp"
|
||||||
|
#include "apps/openmw/mwbase/world.hpp"
|
||||||
|
#include "apps/openmw/mwworld/esmstore.hpp"
|
||||||
|
#include "apps/openmw/mwworld/store.hpp"
|
||||||
|
|
||||||
#include "../context.hpp"
|
#include "../context.hpp"
|
||||||
|
|
||||||
namespace MWLua
|
namespace MWLua
|
||||||
@ -45,6 +50,16 @@ namespace MWLua
|
|||||||
void addClothingBindings(sol::table clothing, const Context& context);
|
void addClothingBindings(sol::table clothing, const Context& context);
|
||||||
void addStaticBindings(sol::table stat, const Context& context);
|
void addStaticBindings(sol::table stat, const Context& context);
|
||||||
void addLightBindings(sol::table light, const Context& context);
|
void addLightBindings(sol::table light, const Context& context);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void addRecordFunctionBinding(sol::table table)
|
||||||
|
{
|
||||||
|
const MWWorld::Store<T>& store = MWBase::Environment::get().getWorld()->getStore().get<T>();
|
||||||
|
|
||||||
|
table["record"] = sol::overload([](const Object& obj) -> const T* { return obj.ptr().get<T>()->mBase; },
|
||||||
|
[&store](
|
||||||
|
const std::string& recordId) -> const T* { return store.find(ESM::RefId::stringRefId(recordId)); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MWLUA_TYPES_H
|
#endif // MWLUA_TYPES_H
|
||||||
|
@ -40,13 +40,8 @@ namespace MWLua
|
|||||||
|
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Weapon>* store
|
addRecordFunctionBinding<ESM::Weapon>(weapon);
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Weapon>();
|
|
||||||
weapon["record"]
|
|
||||||
= sol::overload([](const Object& obj) -> const ESM::Weapon* { return obj.ptr().get<ESM::Weapon>()->mBase; },
|
|
||||||
[store](const std::string& recordId) -> const ESM::Weapon* {
|
|
||||||
return store->find(ESM::RefId::stringRefId(recordId));
|
|
||||||
});
|
|
||||||
sol::usertype<ESM::Weapon> record = context.mLua->sol().new_usertype<ESM::Weapon>("ESM3_Weapon");
|
sol::usertype<ESM::Weapon> record = context.mLua->sol().new_usertype<ESM::Weapon>("ESM3_Weapon");
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Weapon& rec) -> std::string { return "ESM3_Weapon[" + rec.mId.toDebugString() + "]"; };
|
= [](const ESM::Weapon& rec) -> std::string { return "ESM3_Weapon[" + rec.mId.toDebugString() + "]"; };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user