|
|
stranger
|
OP
stranger
Joined: Aug 2014
|
Attempting a setup where I pull a lever to open a door. Pulling it again will close the door. I'm not able to look up the function calls at this second so my code is more pseudocode but it should be pretty obvious. This is what I attempted:
IF
CharacterUsedItem(Character, Lever)
AND
ItemIsClosed(Door)
THEN
OpenItem(Door);
IF
CharacterUsedItem(Character, Lever)
AND
ItemIsOpen(Door)
THEN
CloseItem(Door);
When this executes, nothing appears to happen. I believe this is because the first script executes, opens the door, then the second condition is evaluated which is now true and the door closes. I'm an experienced programmer but still having some issues wrapping my head around Osiris. I don't think theres an "Else" I can make use of here so I'm not sure what other way I can accomplish this. How can this be better written?
|
|
|
|
apprentice
|
apprentice
Joined: Sep 2017
|
Try doing it with a flag....DoorOpen
- When you pull the lever, set the flag DoorOpen - Then set a watch on the flag (if it is set ... open the door) - If you pull the lever and flag is OPEN... then clear the flag DoorOpen - Set a watch on the ObjectFlagCleared to close the door.
|
|
|
|
stranger
|
OP
stranger
Joined: Aug 2014
|
Hmm, I attempted this but I'm seeing the same result. Is this what you had in mind?
IF
CharacterUsedItem(CHARACTERGUID_S_GLO_CharacterCreationDummy_001_da072fe7-fdd5-42ae-9139-8bd4b9fca406, ITEMGUID_TestLever_db55b1f7-f54f-45d2-af31-3a3aea1a648f)
AND
GlobalGetFlag("DOOROPEN", 0)
THEN
GlobalSetFlag("DOOROPEN");
IF
GlobalFlagSet("DOOROPEN")
THEN
ItemOpen(ITEMGUID_TestDoor_18d397cb-736f-4e5f-8b03-278c6e3437d9);
IF
CharacterUsedItem(CHARACTERGUID_S_GLO_CharacterCreationDummy_001_da072fe7-fdd5-42ae-9139-8bd4b9fca406, ITEMGUID_TestLever_db55b1f7-f54f-45d2-af31-3a3aea1a648f)
AND
GlobalGetFlag("DOOROPEN", 1)
THEN
GlobalClearFlag("DOOROPEN");
IF
GlobalFlagCleared("DOOROPEN")
THEN
ItemClose(ITEMGUID_TestDoor_18d397cb-736f-4e5f-8b03-278c6e3437d9);
This does the same thing as before, just with more code. Sets the flag and opens the door. Then the game evaluates the next part, sees I am using the lever and the flag is set.. so it clears the flag which closes the door. I wish I could do something like.. "CharacterStopUsingItem" to force no other scripts to execute on the "CharacterUsedItem"
|
|
|
|
enthusiast
|
enthusiast
Joined: Jan 2010
|
Your first try was almost correct. Here's an example from the game: 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. //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
|
|
|
|
journeyman
|
journeyman
Joined: Jul 2014
|
Isn't this what Queries are for?
QRY
QRY_MyMod_IsntOpen((ITEMGUID)Door)
AND
ItemIsOpen(Door)
THEN
ItemCloseAndLock(Door);
DB_NOOP;
IF
CharacterUsedItem(Character, Lever)
AND
DB_MyMod_LeverDoor(Lever, Door)
AND
QRY_MyMod_IsntOpen(Door)
THEN
ItemUnlockAndOpen(Door);
I am genuingly asking, as I have run into this and solve it with Modulo, but having been doing reading into Queries, I feel like this should work.
Last edited by Sinistralis; 24/10/17 11:43 PM.
|
|
|
|
journeyman
|
journeyman
Joined: Oct 2017
|
I tested this and it works for me fine.
IF
CharacterUsedItem(_Player, _MyLever)
AND
ItemIsClosed(_MyDoor,1)
THEN
ItemOpen(_MyDoor);
IF
CharacterUsedItem(_Player, _MyLever)
AND
ItemIsOpened(_MyDoor,1)
THEN
ItemClose(_MyDoor);
|
|
|
|
stranger
|
OP
stranger
Joined: Aug 2014
|
Your first try was almost correct. Here's an example from the game: 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. Worked perfectly! Thanks!
|
|
|
|
|
|