Your first try was almost correct. Here's an example from the game:

Code
IF
CharacterUsedItem(_,ITEMGUID_S_RC_DF_WitchCellar_Lever_000_77969906-64c9-45cd-9740-2270e5b3d5ab)
AND
ItemIsOpened(ITEMGUID_S_RC_DF_WitchCellar_Door_000_27406f3b-4e45-482b-a386-581fd5b99aa6,0)
THEN
ItemUnlockAndOpen(ITEMGUID_S_RC_DF_WitchCellar_Door_000_27406f3b-4e45-482b-a386-581fd5b99aa6);

IF
CharacterUsedItem(_,ITEMGUID_S_RC_DF_WitchCellar_Lever_000_77969906-64c9-45cd-9740-2270e5b3d5ab)
AND
ItemIsOpened(ITEMGUID_S_RC_DF_WitchCellar_Door_000_27406f3b-4e45-482b-a386-581fd5b99aa6,1)
THEN
ItemCloseAndLock(ITEMGUID_S_RC_DF_WitchCellar_Door_000_27406f3b-4e45-482b-a386-581fd5b99aa6,"NO_KEY");


The ItemUnlockAndOpen and ItemCloseAndLock procedures are from the shared __PROC story script.

They should be available to custom campaigns, if you're working on one.

Code
//REGION Doors
PROC
ItemCloseAndLock((ITEMGUID)_Item,(STRING)_Key)
THEN
ItemClose(_Item);
ItemLock(_Item,_Key);

PROC
ItemUnlockAndOpen((ITEMGUID)_Item)
THEN
ItemUnLock(_Item);
ItemOpen(_Item);
//END_REGION


LSLib Contributor | My Mods: DOS2, DOS2DE | 560K Steam Workshop Subscribers