I am a new user to the CS, and have only been tinkering with it for a few days, started out designing my first dungeon and after finishing that project started messing with scripting objects. With a few programming courses from college under my belt, oblivion scripting still befuddles me a bit however I did manage to make a few successful scripts for my needs during dungeon creation. However my current endeavor is turning up a little sour.
What I am trying to do is make a script for a locked gate to check for the existence of a key in the players inventory (I know by default it does this, but I want to remove the key upon gate activation which is why I am trying to script it into the gate itself). I got the script to work for unlocking, removing the key and opening/closing the gate after, however it runs regardless of the keys existence so I need to check for the key. After doing some searching I tried the HasVariable (It sounded like what I was looking for) but could never get it to work.
Here is what I have so far:
scn TestWorkspaceKeyRemoveSCRIPTshort DoOnceref mySelfbegin OnActivate if DoOnce == 0 if player.HasVariable 01001216 == 1 myself.unlock myself.activate player.RemoveItem 01001216 1 set DoOnce to 1 else message "This gate requires a key." endif else myself.activate return endifend
I know I am probably doing it wrong, but I have tried calling for HasVariable in many different ways. FormID, RefID, String, etc. Nothing has worked so far, HasVariable has never returned a 1 and the wiki entry for HasVariable is a little vague (to me anyway, being new to the CS) as far as proper syntax is concerned. My only indication that tells me I am on the right track is the fact that the CS Script Editor doesn't pop up with an error when I save the script for testing. If there is some other function that would be better for what I am trying to do, or if I need to use a different begin sequence to check for the key(GameMode, MenuMode, etc) I haven't a clue.
Many thanks to anyone who can shed some light on what I am doing wrong here.