Add barter gold bindings

This commit is contained in:
Evil Eye 2025-12-13 20:09:30 +01:00 committed by Alexei Kotov
parent 5a022532fd
commit 25d1b18b75
2 changed files with 29 additions and 0 deletions

View File

@ -421,6 +421,22 @@ namespace MWLua
return ptr.getClass().getCapacity(ptr); return ptr.getClass().getCapacity(ptr);
}; };
actor["getBarterGold"] = [](const Object& object) -> int {
const MWWorld::Ptr ptr = object.ptr();
return ptr.getClass().getCreatureStats(ptr).getGoldPool();
};
actor["setBarterGold"] = [context](const SelfObject& object, int gold) {
if (gold < 0)
throw std::runtime_error("Barter gold must be positive");
context.mLuaManager->addAction(
[obj = Object(object), gold] {
const MWWorld::Ptr ptr = obj.ptr();
ptr.getClass().getCreatureStats(ptr).setGoldPool(gold);
},
"SetBarterGoldAction");
};
actor["_onHit"] = [context](const SelfObject& self, const sol::table& options) { actor["_onHit"] = [context](const SelfObject& self, const sol::table& options) {
sol::optional<sol::table> damageLua = options.get<sol::optional<sol::table>>("damage"); sol::optional<sol::table> damageLua = options.get<sol::optional<sol::table>>("damage");
std::map<std::string, float> damageCpp; std::map<std::string, float> damageCpp;

View File

@ -22,6 +22,19 @@
-- @param openmw.core#GameObject actor -- @param openmw.core#GameObject actor
-- @return #number -- @return #number
---
-- Get the actor's current barter gold.
-- @function [parent=#Actor] getBarterGold
-- @param openmw.core#GameObject actor
-- @return #number
---
-- Set the actor's current barter gold.
-- Can only be used on self in local scripts.
-- @function [parent=#Actor] setBarterGold
-- @param openmw.core#GameObject actor
-- @param #number amount
--- ---
-- Check if the given actor is dead (health reached 0, so death process started). -- Check if the given actor is dead (health reached 0, so death process started).
-- @function [parent=#Actor] isDead -- @function [parent=#Actor] isDead