mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 08:15:37 +00:00
Minor API inconsistencies
This commit is contained in:
parent
13deb0fba8
commit
c9eaeb47d5
3 changed files with 12 additions and 5 deletions
|
@ -312,11 +312,17 @@ namespace MWLua
|
|||
};
|
||||
objectT["ownerFactionId"] = sol::property(getOwnerFactionId, setOwnerFactionId);
|
||||
|
||||
auto getOwnerFactionRank = [](const ObjectT& o) -> int { return o.ptr().getCellRef().getFactionRank(); };
|
||||
auto setOwnerFactionRank = [](const ObjectT& object, int factionRank) {
|
||||
auto getOwnerFactionRank = [](const ObjectT& o) -> sol::optional<int> {
|
||||
int rank = o.ptr().getCellRef().getFactionRank();
|
||||
if (rank < 0)
|
||||
return sol::nullopt;
|
||||
else
|
||||
return rank;
|
||||
};
|
||||
auto setOwnerFactionRank = [](const ObjectT& object, sol::optional<int> factionRank) {
|
||||
if (std::is_same_v<ObjectT, LObject> && !dynamic_cast<const SelfObject*>(&object))
|
||||
throw std::runtime_error("Local scripts can set an owner faction rank only on self");
|
||||
object.ptr().getCellRef().setFactionRank(factionRank);
|
||||
object.ptr().getCellRef().setFactionRank(factionRank.value_or(-1));
|
||||
};
|
||||
objectT["ownerFactionRank"] = sol::property(getOwnerFactionRank, setOwnerFactionRank);
|
||||
|
||||
|
|
|
@ -133,7 +133,8 @@ namespace LuaUtil
|
|||
|
||||
// Lua bindings for Box
|
||||
util["box"] = sol::overload([](const Vec3& center, const Vec3& halfSize) { return Box(center, halfSize); },
|
||||
[](const TransformM& transform) { return Box(transform.mM); });
|
||||
[](const TransformM& transform) { return Box(transform.mM); },
|
||||
[](const TransformQ& transform) { return Box(Vec3(), Vec3(1, 1, 1), transform.mQ); });
|
||||
sol::usertype<Box> boxType = lua.new_usertype<Box>("Box");
|
||||
boxType["center"] = sol::readonly_property([](const Box& b) { return b.mCenter; });
|
||||
boxType["halfSize"] = sol::readonly_property([](const Box& b) { return b.mHalfSize; });
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
-- @field openmw.util#Transform startingRotation The object original rotation
|
||||
-- @field #string ownerRecordId NPC who owns the object (nil if missing). Global and self scripts can set the value.
|
||||
-- @field #string ownerFactionId Faction who owns the object (nil if missing). Global and self scripts can set the value.
|
||||
-- @field #number ownerFactionRank Rank required to be allowed to pick up the object. Global and self scripts can set the value.
|
||||
-- @field #number ownerFactionRank Rank required to be allowed to pick up the object (`nil` if any rank is allowed). Global and self scripts can set the value.
|
||||
-- @field #Cell cell The cell where the object currently is. During loading a game and for objects in an inventory or a container `cell` is nil.
|
||||
-- @field #GameObject parentContainer Container or actor that contains (or has in inventory) this object. It is nil if the object is in a cell.
|
||||
-- @field #any type Type of the object (one of the tables from the package @{openmw.types#types}).
|
||||
|
|
Loading…
Reference in a new issue