Add isTeleportingEnabled and setTeleportingEnabled

macos_ci_fix
Zackhasacat 1 year ago
parent c058b30322
commit f4d349070c

@ -138,6 +138,19 @@ namespace MWLua
throw std::runtime_error("The argument must be a player.");
return input->getControlSwitch(key);
};
player["isTeleportingEnabled"] = [](const Object& player) -> bool {
if (player.ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr())
throw std::runtime_error("The argument must be a player.");
return MWBase::Environment::get().getWorld()->isTeleportingEnabled();
};
player["setTeleportingEnabled"] = [context](const Object& player, bool state) {
if (player.ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr())
throw std::runtime_error("The argument must be a player.");
if (dynamic_cast<const LObject*>(&player) && !dynamic_cast<const SelfObject*>(&player))
throw std::runtime_error("Only player and global scripts can toggle teleportation.");
context.mLuaManager->addAction([state] { MWBase::Environment::get().getWorld()->enableTeleporting(state); },
"toggleTeleportingAction");
};
player["setControlSwitch"] = [input](const Object& player, std::string_view key, bool v) {
if (player.ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr())
throw std::runtime_error("The argument must be a player.");

@ -919,13 +919,26 @@
-- @function [parent=#Player] getCrimeLevel
-- @param openmw.core#GameObject player
-- @return #number
---
-- Whether the character generation for this player is finished.
-- @function [parent=#Player] isCharGenFinished
-- @param openmw.core#GameObject player
-- @return #boolean
---
-- Whether teleportation for this player is enabled.
-- @function [parent=#Player] isTeleportingEnabled
-- @param openmw.core#GameObject player
-- @param #boolean player
-- @return #boolean
---
-- Enables or disables teleportation for this player.
-- @function [parent=#Player] setTeleportingEnabled
-- @param openmw.core#GameObject player
-- @param #boolean state True to enable teleporting, false to disable.
---
-- Returns a list containing quests @{#PlayerQuest} for the specified player, indexed by quest ID.
-- @function [parent=#Player] quests

Loading…
Cancel
Save