Skip to content

Commit

Permalink
Merge branch 'teleport_block' into 'master'
Browse files Browse the repository at this point in the history
Lua: Add isTeleportingEnabled and setTeleportingEnabled to types.Player

See merge request OpenMW/openmw!3519
  • Loading branch information
psi29a committed Oct 27, 2023
2 parents 8380da2 + 6a67118 commit f724b05
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
12 changes: 12 additions & 0 deletions apps/openmw/mwlua/types/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ 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"] = [](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) {
if (player.ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr())
throw std::runtime_error("The argument must be a player.");
Expand Down
15 changes: 14 additions & 1 deletion files/lua_api/openmw/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f724b05

Please sign in to comment.