1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-11-29 12:04:31 +00:00

Enforced local scripts can only modify self.

Updated documentation to use self and player in examples.
This commit is contained in:
Nova 2025-11-13 14:45:49 -05:00 committed by Alexei Kotov
parent 5a76783616
commit 87dc3cd0e8
2 changed files with 5 additions and 2 deletions

View file

@ -248,6 +248,9 @@ namespace MWLua
}; };
npc["setWerewolf"] = [context](const Object& obj, bool werewolf) -> void { npc["setWerewolf"] = [context](const Object& obj, bool werewolf) -> void {
if (dynamic_cast<const LObject*>(&obj) && !dynamic_cast<const SelfObject*>(&obj))
throw std::runtime_error("Local scripts can modify only self");
const MWWorld::Ptr& ptr = obj.ptr(); const MWWorld::Ptr& ptr = obj.ptr();
if (!ptr.getClass().isNpc()) if (!ptr.getClass().isNpc())
throw std::runtime_error("NPC or Player expected"); throw std::runtime_error("NPC or Player expected");

View file

@ -1095,9 +1095,9 @@
-- @param openmw.core#GameObject actor The NPC or player to transform -- @param openmw.core#GameObject actor The NPC or player to transform
-- @param #boolean werewolf True to transform into werewolf, false to transform back to normal -- @param #boolean werewolf True to transform into werewolf, false to transform back to normal
-- @usage -- Transform player into werewolf in a global script -- @usage -- Transform player into werewolf in a global script
-- types.NPC.setWerewolf(player, true) -- player.type.setWerewolf(player, true)
-- @usage -- Transform self back to normal in a local script -- @usage -- Transform self back to normal in a local script
-- types.NPC.setWerewolf(self, false) -- self.type.setWerewolf(self, false)
--- ---
-- Returns the read-only @{#NpcRecord} of an NPC -- Returns the read-only @{#NpcRecord} of an NPC