1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-28 22:39:42 +00:00

Merge branch 'teleport_block' into 'master'

Lua: Add isTeleportingEnabled and setTeleportingEnabled to types.Player

See merge request OpenMW/openmw!3519
This commit is contained in:
psi29a 2023-10-27 17:37:04 +00:00
commit f724b05c57
2 changed files with 26 additions and 1 deletions

View file

@ -138,6 +138,18 @@ namespace MWLua
throw std::runtime_error("The argument must be a player."); throw std::runtime_error("The argument must be a player.");
return input->getControlSwitch(key); 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"] = [](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.");
MWBase::Environment::get().getWorld()->enableTeleporting(state);
};
player["setControlSwitch"] = [input](const Object& player, std::string_view key, bool v) { player["setControlSwitch"] = [input](const Object& player, std::string_view key, bool v) {
if (player.ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr()) if (player.ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr())
throw std::runtime_error("The argument must be a player."); throw std::runtime_error("The argument must be a player.");

View file

@ -926,6 +926,19 @@
-- @param openmw.core#GameObject player -- @param openmw.core#GameObject player
-- @return #boolean -- @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. -- Returns a list containing quests @{#PlayerQuest} for the specified player, indexed by quest ID.
-- @function [parent=#Player] quests -- @function [parent=#Player] quests