Skip to content

Allow Lua to access lock and trap data for doors and containers

Zackhasacat requested to merge zackhasacat/openmw:lua_lock_trap into master

This MR adds types.Lockable.lockLevel,setLockLevel,trapId,setTrapId.

When you call the functions, you can provide either a container or a door, in either case it will work.

setLockLevel and setTrapId are only available from global scripts. Not sure if it would make sense for self to be able to access here as well.

Traps are just spells in the game, so you can try the commands like this, after selected a door or container with the console, and typing in "luag":

types.Lockable.setLockLevel(selected,100)--sets a object's lock level

types.Lockable.setLocked(selected,false)--will set an object as unlocked, won't be saved

types.Lockable.getLockLevel(selected)--returns what level the object is locked at

types.Lockable.setTrapSpell(selected,"soul trap")--sets the trap on the object

types.Lockable.getTrapSpell(selected)

I've now added a global and local(to containers and doors) interface. You can use it like so:

Global: I.Lockable.lock(door,100) I.Lockable.unlock(door)

From a door/container: I.Lockable.lock(100)--will lock the door the script is running on I.Lockable.unlock()--will unlock the door the script is running on

You can also use the interfaces through events, from any script.

door.sendEvent("unlock") door.sendEvent("lock",100)

Documentation is added.

Edited by Zackhasacat

Merge request reports