diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index d0c38f31b1..e05466740c 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -68,7 +68,7 @@ namespace MWLua { auto* lua = context.mLua; sol::table api(lua->sol(), sol::create); - api["API_REVISION"] = 36; + api["API_REVISION"] = 37; api["quit"] = [lua]() { Log(Debug::Warning) << "Quit requested by a Lua script.\n" << lua->debugTraceback(); MWBase::Environment::get().getStateManager()->requestQuit(); diff --git a/apps/openmw/mwlua/types/actor.cpp b/apps/openmw/mwlua/types/actor.cpp index 39bca897e8..d9a4b2e13f 100644 --- a/apps/openmw/mwlua/types/actor.cpp +++ b/apps/openmw/mwlua/types/actor.cpp @@ -122,13 +122,14 @@ namespace MWLua { "CarriedLeft", MWWorld::InventoryStore::Slot_CarriedLeft }, { "Ammunition", MWWorld::InventoryStore::Slot_Ammunition } })); - actor["stance"] = [](const Object& o) { + actor["getStance"] = [](const Object& o) { const MWWorld::Class& cls = o.ptr().getClass(); if (cls.isActor()) return cls.getCreatureStats(o.ptr()).getDrawState(); else throw std::runtime_error("Actor expected"); }; + actor["stance"] = actor["getStance"]; // for compatibility; should be removed later actor["setStance"] = [](const SelfObject& self, int stance) { const MWWorld::Class& cls = self.ptr().getClass(); if (!cls.isActor()) @@ -177,19 +178,24 @@ namespace MWLua const MWWorld::Class& cls = o.ptr().getClass(); return cls.getMaxSpeed(o.ptr()) > 0; }; - actor["runSpeed"] = [](const Object& o) { + actor["getRunSpeed"] = [](const Object& o) { const MWWorld::Class& cls = o.ptr().getClass(); return cls.getRunSpeed(o.ptr()); }; - actor["walkSpeed"] = [](const Object& o) { + actor["getWalkSpeed"] = [](const Object& o) { const MWWorld::Class& cls = o.ptr().getClass(); return cls.getWalkSpeed(o.ptr()); }; - actor["currentSpeed"] = [](const Object& o) { + actor["getCurrentSpeed"] = [](const Object& o) { const MWWorld::Class& cls = o.ptr().getClass(); return cls.getCurrentSpeed(o.ptr()); }; + // for compatibility; should be removed later + actor["runSpeed"] = actor["getRunSpeed"]; + actor["walkSpeed"] = actor["getWalkSpeed"]; + actor["currentSpeed"] = actor["getCurrentSpeed"]; + actor["isOnGround"] = [](const LObject& o) { return MWBase::Environment::get().getWorld()->isOnGround(o.ptr()); }; actor["isSwimming"] @@ -231,7 +237,8 @@ namespace MWLua else return sol::make_object(lua, LObject(*it)); }; - actor["equipment"] = sol::overload(getAllEquipment, getEquipmentFromSlot); + actor["getEquipment"] = sol::overload(getAllEquipment, getEquipmentFromSlot); + actor["equipment"] = actor["getEquipment"]; // for compatibility; should be removed later actor["hasEquipped"] = [](const Object& o, const Object& item) { const MWWorld::Ptr& ptr = o.ptr(); if (!ptr.getClass().hasInventoryStore(ptr)) diff --git a/apps/openmw/mwlua/types/misc.cpp b/apps/openmw/mwlua/types/misc.cpp index 17b51898de..a6d73b5dac 100644 --- a/apps/openmw/mwlua/types/misc.cpp +++ b/apps/openmw/mwlua/types/misc.cpp @@ -38,13 +38,14 @@ namespace MWLua object.ptr().getCellRef().setSoul(creature); }; - miscellaneous["soul"] = [](const Object& object) -> sol::optional { + miscellaneous["getSoul"] = [](const Object& object) -> sol::optional { ESM::RefId soul = object.ptr().getCellRef().getSoul(); if (soul.empty()) return sol::nullopt; else return soul.serializeText(); }; + miscellaneous["soul"] = miscellaneous["getSoul"]; // for compatibility; should be removed later sol::usertype record = context.mLua->sol().new_usertype("ESM3_Miscellaneous"); record[sol::meta_function::to_string] diff --git a/files/data/scripts/omw/camera/camera.lua b/files/data/scripts/omw/camera/camera.lua index 6aaa807bad..1280a574fa 100644 --- a/files/data/scripts/omw/camera/camera.lua +++ b/files/data/scripts/omw/camera/camera.lua @@ -104,7 +104,7 @@ local function updateVanity(dt) end local function updateSmoothedSpeed(dt) - local speed = Actor.currentSpeed(self) + local speed = Actor.getCurrentSpeed(self) speed = speed / (1 + speed / 500) local maxDelta = 300 * dt smoothedSpeed = smoothedSpeed + util.clamp(speed - smoothedSpeed, -maxDelta, maxDelta) @@ -153,7 +153,7 @@ local function updateStandingPreview() third_person.standingPreview = false return end - local standingStill = Actor.currentSpeed(self) == 0 and Actor.stance(self) == Actor.STANCE.Nothing + local standingStill = Actor.getCurrentSpeed(self) == 0 and Actor.getStance(self) == Actor.STANCE.Nothing if standingStill and mode == MODE.ThirdPerson then third_person.standingPreview = true camera.setMode(MODE.Preview) diff --git a/files/data/scripts/omw/camera/head_bobbing.lua b/files/data/scripts/omw/camera/head_bobbing.lua index 5b48c94fed..8972364ebb 100644 --- a/files/data/scripts/omw/camera/head_bobbing.lua +++ b/files/data/scripts/omw/camera/head_bobbing.lua @@ -30,7 +30,7 @@ local sampleArc = function(x) return 1 - math.cos(x * halfArc) end local arcHeight = sampleArc(1) function M.update(dt, smoothedSpeed) - local speed = Actor.currentSpeed(self) + local speed = Actor.getCurrentSpeed(self) speed = speed / (1 + speed / 500) -- limit bobbing frequency if the speed is very high totalMovement = totalMovement + speed * dt if not M.enabled or camera.getMode() ~= camera.MODE.FirstPerson then diff --git a/files/data/scripts/omw/camera/move360.lua b/files/data/scripts/omw/camera/move360.lua index 08e4b09f45..e8bc761cfd 100644 --- a/files/data/scripts/omw/camera/move360.lua +++ b/files/data/scripts/omw/camera/move360.lua @@ -31,7 +31,7 @@ end function M.onFrame(dt) if core.isWorldPaused() then return end - local newActive = M.enabled and Actor.stance(self) == Actor.STANCE.Nothing + local newActive = M.enabled and Actor.getStance(self) == Actor.STANCE.Nothing if newActive and not active then turnOn() elseif not newActive and active then diff --git a/files/data/scripts/omw/camera/third_person.lua b/files/data/scripts/omw/camera/third_person.lua index c28cbe2a4f..66fdef7bf4 100644 --- a/files/data/scripts/omw/camera/third_person.lua +++ b/files/data/scripts/omw/camera/third_person.lua @@ -85,7 +85,7 @@ end local function updateState() local mode = camera.getMode() local oldState = state - if Actor.stance(self) ~= Actor.STANCE.Nothing and mode == MODE.ThirdPerson then + if Actor.getStance(self) ~= Actor.STANCE.Nothing and mode == MODE.ThirdPerson then state = STATE.Combat elseif Actor.isSwimming(self) then state = STATE.Swimming @@ -94,7 +94,7 @@ local function updateState() elseif not state then state = defaultShoulder end - if (mode == MODE.ThirdPerson or Actor.currentSpeed(self) > 0 or state ~= oldState or noThirdPersonLastFrame) + if (mode == MODE.ThirdPerson or Actor.getCurrentSpeed(self) > 0 or state ~= oldState or noThirdPersonLastFrame) and (state == STATE.LeftShoulder or state == STATE.RightShoulder) then if autoSwitchShoulder then trySwitchShoulder() diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index aebb1f9fc4..2e9312c81e 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -71,19 +71,19 @@ --- -- Speed of running. For dead actors it still returns a positive value. --- @function [parent=#Actor] runSpeed +-- @function [parent=#Actor] getRunSpeed -- @param openmw.core#GameObject actor -- @return #number --- -- Speed of walking. For dead actors it still returns a positive value. --- @function [parent=#Actor] walkSpeed +-- @function [parent=#Actor] getWalkSpeed -- @param openmw.core#GameObject actor -- @return #number --- -- Current speed. --- @function [parent=#Actor] currentSpeed +-- @function [parent=#Actor] getCurrentSpeed -- @param openmw.core#GameObject actor -- @return #number @@ -101,7 +101,7 @@ --- -- Returns the current stance (whether a weapon/spell is readied), see the list of @{#STANCE} values. --- @function [parent=#Actor] stance +-- @function [parent=#Actor] getStance -- @param openmw.core#GameObject actor -- @return #number @@ -114,7 +114,7 @@ --- -- Returns `true` if the item is equipped on the actor. --- @function [parent=#Actor] isEquipped +-- @function [parent=#Actor] hasEquipped -- @param openmw.core#GameObject actor -- @param openmw.core#GameObject item -- @return #boolean @@ -131,7 +131,7 @@ -- See @{#EQUIPMENT_SLOT}. Returns empty table if the actor doesn't have -- equipment slots. -- 2) With two arguments: returns an item equipped to the given slot. --- @function [parent=#Actor] equipment +-- @function [parent=#Actor] getEquipment -- @param openmw.core#GameObject actor -- @param #number slot Optional number of the equipment slot -- @return #EquipmentTable, openmw.core#GameObject @@ -848,7 +848,7 @@ --- -- Returns the read-only soul of a miscellaneous item --- @function [parent=#Miscellaneous] soul +-- @function [parent=#Miscellaneous] getSoul -- @param openmw.core#GameObject object -- @return #string