Hi Red,
Is there a way with the API to get whether a door/chest is locked or not?
Hi Red,
Is there a way with the API to get whether a door/chest is locked or not?
Yes, but it's unfortunately not very intuitive...
The "locked" state is currently stored in the info field of the object, so if you want to check if a door or chest is locked, just check if the info is not 0, e.g:
Argh, looks like even if you set a status of a door to open via the API, if it's locked you still can't open it.
Console states "Door <long id> is locked..."
EDIT: Wait a minute... not 1 its 100 let me try that...
EDIT2: Nope, setting to 100 still doesn't override the lock.
Just to be clear, my objective to use the API to open and close a door (and chests) that is are locked, not remove the lock.
Yeah, unfortunately doors cannot be opened if they're locked... it might work if you first set the "info" to 0, then change the status, then re-assign the old info value, but that's not a good solution...
But I can change the behaviour with the next update, so the API will always be able to open doors, even if they're locked
//edit: just a small question: is it also important that the door plays the open animation (and also get blocked by obstacles)? Or would you like to forcefully set the new status (without animation, just force the door to be fully opened instantly, for example)?
Opening with animation and blocked by obstacles would be ideal for what I have in mind
I see The next update will have a new, optional "instant" parameter for the "setStatus()" method: if set to true, the new status will be set immediately (no animation, not getting blocked etc), and if you set it to false, the game will smoothly open the door (plays the animation and the door will also be blocked by obstacles)
But calling "setStatus()" through the API will always work with the next update, even if the door is locked.
it might work if you first set the "info" to 0, then change the status, then re-assign the old info value
This workaround actually works
But I will update my code with a cleaner method once the new API is ready
I'm happy to hear the workaround worked But I'd also suggest to change that once the new API is available
Don’t have an account yet? Create a new account now and be part of our community!