mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-01 00:32:52 +00:00
Rename some functions in Lua API from aaa
to getAaa
(for consistency with setAaa
)
This commit is contained in:
parent
1f0aede634
commit
067df2d07e
@ -68,7 +68,7 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
auto* lua = context.mLua;
|
auto* lua = context.mLua;
|
||||||
sol::table api(lua->sol(), sol::create);
|
sol::table api(lua->sol(), sol::create);
|
||||||
api["API_REVISION"] = 36;
|
api["API_REVISION"] = 37;
|
||||||
api["quit"] = [lua]() {
|
api["quit"] = [lua]() {
|
||||||
Log(Debug::Warning) << "Quit requested by a Lua script.\n" << lua->debugTraceback();
|
Log(Debug::Warning) << "Quit requested by a Lua script.\n" << lua->debugTraceback();
|
||||||
MWBase::Environment::get().getStateManager()->requestQuit();
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||||
|
@ -122,13 +122,14 @@ namespace MWLua
|
|||||||
{ "CarriedLeft", MWWorld::InventoryStore::Slot_CarriedLeft },
|
{ "CarriedLeft", MWWorld::InventoryStore::Slot_CarriedLeft },
|
||||||
{ "Ammunition", MWWorld::InventoryStore::Slot_Ammunition } }));
|
{ "Ammunition", MWWorld::InventoryStore::Slot_Ammunition } }));
|
||||||
|
|
||||||
actor["stance"] = [](const Object& o) {
|
actor["getStance"] = [](const Object& o) {
|
||||||
const MWWorld::Class& cls = o.ptr().getClass();
|
const MWWorld::Class& cls = o.ptr().getClass();
|
||||||
if (cls.isActor())
|
if (cls.isActor())
|
||||||
return cls.getCreatureStats(o.ptr()).getDrawState();
|
return cls.getCreatureStats(o.ptr()).getDrawState();
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Actor expected");
|
throw std::runtime_error("Actor expected");
|
||||||
};
|
};
|
||||||
|
actor["stance"] = actor["getStance"]; // for compatibility; should be removed later
|
||||||
actor["setStance"] = [](const SelfObject& self, int stance) {
|
actor["setStance"] = [](const SelfObject& self, int stance) {
|
||||||
const MWWorld::Class& cls = self.ptr().getClass();
|
const MWWorld::Class& cls = self.ptr().getClass();
|
||||||
if (!cls.isActor())
|
if (!cls.isActor())
|
||||||
@ -177,19 +178,24 @@ namespace MWLua
|
|||||||
const MWWorld::Class& cls = o.ptr().getClass();
|
const MWWorld::Class& cls = o.ptr().getClass();
|
||||||
return cls.getMaxSpeed(o.ptr()) > 0;
|
return cls.getMaxSpeed(o.ptr()) > 0;
|
||||||
};
|
};
|
||||||
actor["runSpeed"] = [](const Object& o) {
|
actor["getRunSpeed"] = [](const Object& o) {
|
||||||
const MWWorld::Class& cls = o.ptr().getClass();
|
const MWWorld::Class& cls = o.ptr().getClass();
|
||||||
return cls.getRunSpeed(o.ptr());
|
return cls.getRunSpeed(o.ptr());
|
||||||
};
|
};
|
||||||
actor["walkSpeed"] = [](const Object& o) {
|
actor["getWalkSpeed"] = [](const Object& o) {
|
||||||
const MWWorld::Class& cls = o.ptr().getClass();
|
const MWWorld::Class& cls = o.ptr().getClass();
|
||||||
return cls.getWalkSpeed(o.ptr());
|
return cls.getWalkSpeed(o.ptr());
|
||||||
};
|
};
|
||||||
actor["currentSpeed"] = [](const Object& o) {
|
actor["getCurrentSpeed"] = [](const Object& o) {
|
||||||
const MWWorld::Class& cls = o.ptr().getClass();
|
const MWWorld::Class& cls = o.ptr().getClass();
|
||||||
return cls.getCurrentSpeed(o.ptr());
|
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"]
|
actor["isOnGround"]
|
||||||
= [](const LObject& o) { return MWBase::Environment::get().getWorld()->isOnGround(o.ptr()); };
|
= [](const LObject& o) { return MWBase::Environment::get().getWorld()->isOnGround(o.ptr()); };
|
||||||
actor["isSwimming"]
|
actor["isSwimming"]
|
||||||
@ -231,7 +237,8 @@ namespace MWLua
|
|||||||
else
|
else
|
||||||
return sol::make_object(lua, LObject(*it));
|
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) {
|
actor["hasEquipped"] = [](const Object& o, const Object& item) {
|
||||||
const MWWorld::Ptr& ptr = o.ptr();
|
const MWWorld::Ptr& ptr = o.ptr();
|
||||||
if (!ptr.getClass().hasInventoryStore(ptr))
|
if (!ptr.getClass().hasInventoryStore(ptr))
|
||||||
|
@ -38,13 +38,14 @@ namespace MWLua
|
|||||||
|
|
||||||
object.ptr().getCellRef().setSoul(creature);
|
object.ptr().getCellRef().setSoul(creature);
|
||||||
};
|
};
|
||||||
miscellaneous["soul"] = [](const Object& object) -> sol::optional<std::string> {
|
miscellaneous["getSoul"] = [](const Object& object) -> sol::optional<std::string> {
|
||||||
ESM::RefId soul = object.ptr().getCellRef().getSoul();
|
ESM::RefId soul = object.ptr().getCellRef().getSoul();
|
||||||
if (soul.empty())
|
if (soul.empty())
|
||||||
return sol::nullopt;
|
return sol::nullopt;
|
||||||
else
|
else
|
||||||
return soul.serializeText();
|
return soul.serializeText();
|
||||||
};
|
};
|
||||||
|
miscellaneous["soul"] = miscellaneous["getSoul"]; // for compatibility; should be removed later
|
||||||
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]
|
||||||
|
@ -104,7 +104,7 @@ local function updateVanity(dt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function updateSmoothedSpeed(dt)
|
local function updateSmoothedSpeed(dt)
|
||||||
local speed = Actor.currentSpeed(self)
|
local speed = Actor.getCurrentSpeed(self)
|
||||||
speed = speed / (1 + speed / 500)
|
speed = speed / (1 + speed / 500)
|
||||||
local maxDelta = 300 * dt
|
local maxDelta = 300 * dt
|
||||||
smoothedSpeed = smoothedSpeed + util.clamp(speed - smoothedSpeed, -maxDelta, maxDelta)
|
smoothedSpeed = smoothedSpeed + util.clamp(speed - smoothedSpeed, -maxDelta, maxDelta)
|
||||||
@ -153,7 +153,7 @@ local function updateStandingPreview()
|
|||||||
third_person.standingPreview = false
|
third_person.standingPreview = false
|
||||||
return
|
return
|
||||||
end
|
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
|
if standingStill and mode == MODE.ThirdPerson then
|
||||||
third_person.standingPreview = true
|
third_person.standingPreview = true
|
||||||
camera.setMode(MODE.Preview)
|
camera.setMode(MODE.Preview)
|
||||||
|
@ -30,7 +30,7 @@ local sampleArc = function(x) return 1 - math.cos(x * halfArc) end
|
|||||||
local arcHeight = sampleArc(1)
|
local arcHeight = sampleArc(1)
|
||||||
|
|
||||||
function M.update(dt, smoothedSpeed)
|
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
|
speed = speed / (1 + speed / 500) -- limit bobbing frequency if the speed is very high
|
||||||
totalMovement = totalMovement + speed * dt
|
totalMovement = totalMovement + speed * dt
|
||||||
if not M.enabled or camera.getMode() ~= camera.MODE.FirstPerson then
|
if not M.enabled or camera.getMode() ~= camera.MODE.FirstPerson then
|
||||||
|
@ -31,7 +31,7 @@ end
|
|||||||
|
|
||||||
function M.onFrame(dt)
|
function M.onFrame(dt)
|
||||||
if core.isWorldPaused() then return end
|
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
|
if newActive and not active then
|
||||||
turnOn()
|
turnOn()
|
||||||
elseif not newActive and active then
|
elseif not newActive and active then
|
||||||
|
@ -85,7 +85,7 @@ end
|
|||||||
local function updateState()
|
local function updateState()
|
||||||
local mode = camera.getMode()
|
local mode = camera.getMode()
|
||||||
local oldState = state
|
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
|
state = STATE.Combat
|
||||||
elseif Actor.isSwimming(self) then
|
elseif Actor.isSwimming(self) then
|
||||||
state = STATE.Swimming
|
state = STATE.Swimming
|
||||||
@ -94,7 +94,7 @@ local function updateState()
|
|||||||
elseif not state then
|
elseif not state then
|
||||||
state = defaultShoulder
|
state = defaultShoulder
|
||||||
end
|
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
|
and (state == STATE.LeftShoulder or state == STATE.RightShoulder) then
|
||||||
if autoSwitchShoulder then
|
if autoSwitchShoulder then
|
||||||
trySwitchShoulder()
|
trySwitchShoulder()
|
||||||
|
@ -71,19 +71,19 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
-- Speed of running. For dead actors it still returns a positive value.
|
-- 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
|
-- @param openmw.core#GameObject actor
|
||||||
-- @return #number
|
-- @return #number
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Speed of walking. For dead actors it still returns a positive value.
|
-- 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
|
-- @param openmw.core#GameObject actor
|
||||||
-- @return #number
|
-- @return #number
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Current speed.
|
-- Current speed.
|
||||||
-- @function [parent=#Actor] currentSpeed
|
-- @function [parent=#Actor] getCurrentSpeed
|
||||||
-- @param openmw.core#GameObject actor
|
-- @param openmw.core#GameObject actor
|
||||||
-- @return #number
|
-- @return #number
|
||||||
|
|
||||||
@ -101,7 +101,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
-- Returns the current stance (whether a weapon/spell is readied), see the list of @{#STANCE} values.
|
-- 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
|
-- @param openmw.core#GameObject actor
|
||||||
-- @return #number
|
-- @return #number
|
||||||
|
|
||||||
@ -114,7 +114,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
-- Returns `true` if the item is equipped on the actor.
|
-- 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 actor
|
||||||
-- @param openmw.core#GameObject item
|
-- @param openmw.core#GameObject item
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
@ -131,7 +131,7 @@
|
|||||||
-- See @{#EQUIPMENT_SLOT}. Returns empty table if the actor doesn't have
|
-- See @{#EQUIPMENT_SLOT}. Returns empty table if the actor doesn't have
|
||||||
-- equipment slots.
|
-- equipment slots.
|
||||||
-- 2) With two arguments: returns an item equipped to the given slot.
|
-- 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 openmw.core#GameObject actor
|
||||||
-- @param #number slot Optional number of the equipment slot
|
-- @param #number slot Optional number of the equipment slot
|
||||||
-- @return #EquipmentTable, openmw.core#GameObject
|
-- @return #EquipmentTable, openmw.core#GameObject
|
||||||
@ -848,7 +848,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
-- Returns the read-only soul of a miscellaneous item
|
-- Returns the read-only soul of a miscellaneous item
|
||||||
-- @function [parent=#Miscellaneous] soul
|
-- @function [parent=#Miscellaneous] getSoul
|
||||||
-- @param openmw.core#GameObject object
|
-- @param openmw.core#GameObject object
|
||||||
-- @return #string
|
-- @return #string
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user