|
|
|
@ -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.");
|
|
|
|
|