Hello all, trying to figure out an event issue with a placeable. I have a placeable that can be opened (it has inventory). I have included debug statements that print to the chat window so I know what’s going on and what is/is not working. These work fine. Here’s the problem: the script is placed in the placeable’s onOpen event. In the module, when the PC open’s the placeable for the first time, the inventory opens and the PC can manipulate it, but the onOpen event never fires. When the PC closes the placeable and then re-opens it, and on all subsequent uses, the onOpen event fires just fine. So, any idea why the onOpen event won’t fire the first time the placeable is opened? This behavior persists for multiple PCs, after restarting the module, etc.
Could it be that the initial state of the placeable is “opened”?
Thanks! That’s not something I’d considered, but I wasn’t able to find an Opened state in the properties for the placeable. There is an ‘initial state’ drop-down on the Advanced tab, but its only options are ‘default’ and ‘destroyed’.
I ran a quick check in the area’s on_open even. It is displaying the placeable’s state as closed, or rather the GetIsOpen() on that Object returns FALSE, so I assume it means it is closed.
Well, after much experimentation, I can’t determine why this behavior occurs. I swapped all the scripts over to the onUsed event, which has its own issues that I’m working around, but at least it fires every time. I’d rather use onOpen event, so if anyone has knowledge of this onOpen event error, let me know. Thanks!
Is there anything in the chest when first opened?
The OnOpen event fires when the inventory is opened. It has nothing to do with the open/closed animation state (which your placeable doesn’t have, in any case). This can be demonstrated by painting an open chest with contents in the toolset - clicking in game still fires OnOpen as the inventory pane opens.
The event only fires if there is inventory, according to the Lexicon.
Thanks for the input. I thought that might be the issue, so I ensured the Has Inventory checkbox was checked and I threw some items in the inventory for good measure. The onOpen event still didn’t fire until the second time the PC opened the placeable. Still trying to narrow down exactly why this happening, so still experimenting.