mirror of https://github.com/OpenMW/openmw
Add barter gold bindings
This commit is contained in:
parent
5a022532fd
commit
25d1b18b75
|
|
@ -421,6 +421,22 @@ namespace MWLua
|
|||
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) {
|
||||
sol::optional<sol::table> damageLua = options.get<sol::optional<sol::table>>("damage");
|
||||
std::map<std::string, float> damageCpp;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,19 @@
|
|||
-- @param openmw.core#GameObject actor
|
||||
-- @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).
|
||||
-- @function [parent=#Actor] isDead
|
||||
|
|
|
|||
Loading…
Reference in New Issue