I was scripting veeery long ago for TES 4 and kinda lost the hang of it, now that it is all fancy and object orientated and all.
Im trying to get a extremely simple test script running and fail miserably.
Here is what I got:
Scriptname _WOSTest1 extends ObjectReference;defining variablesint valxint valy;some serious stuff going on hereEvent OnActivate(ObjectReference akActionRef)valx = utility.RandomInt( -8 , 5 )valy = utility.RandomInt( -30 , 20 )Debug.MessageBox(valx)Debug.MessageBox(valy)endEvent
Now my questions is:
actually I applied that script onto a dagger which I have created for test purposes.
I am pretty sure I am doing it wrong at that part already. I just duplicated the good ol' iron dagger and applied the script to it.
Now the compiler lets me use "OnActivate" but not something like "OnGrab" or "OnItemAdded" and I do not really understand why.
Since "one does not simply activate an iron dagger" ... I am not sure what to do.
In that simple first tutorial the script was applied onto an object which was already in the world somewhere, so there was a real reference.
In my case, I just want to summon that dagger into my inventory and want to see that two debug messages with two random values.
Now I am not sure how to get that reference for the dagger.
Since I am only able to call stuff like "OnItemAdded" as part of an event, I am not sure how to point to a real reference BEFORE opening an event...
Thats like having a chicken before the egg was there and I am really lost.
Any help?
[Edit] Okay, I was able to use just "OnAddedItem()" but that also does not work.
Throwing the dagger out of the inventory and using the ShowVars command reveals that no random numbers had been generated which and of course I never got any debug messages.
Where is the trick at something so simple?