How to refer to an Activated Object in an OnActivate script?

Post » Tue Jun 19, 2012 1:24 am

I was wondering how you could refer back to the activated object in an OnActivate script attached to it.

This was just to be able to add that same item to the player's inventory (as per vanilla) instead of doing another thing (for which the script is done)...any hint?

Thanks,
Jashkar
User avatar
oliver klosoff
 
Posts: 3436
Joined: Sun Nov 25, 2007 1:02 am

Post » Tue Jun 19, 2012 12:04 am

I had a similar problem and someone solved it for me with a script (I don't have it here but you could recreate it if you can do some scripting)

I had a misc item and I wanted to teleport somewhere and keep the item (add it to inventory). Now I can't script and tried some things with moveto and additem.

The solution was simpler. The standard action for that item (and hopefully for yours or else this won't work) is to add it to the inventory.

SO he gave me a script that did something ON movement to container and the used somethinglike if newcontainer = getplayer etc then move newcontiner to.

The point being: try getting your preferred action on switching containers in combination with newcontainer = getplayer () etc.

(for correct commands see wiki,or my mod (aezeal's castle: look for the dwemer puzzle cube and on loading prepare for holding enter for 30 secs due to onemillion navmesh errors.)
User avatar
Danial Zachery
 
Posts: 3451
Joined: Fri Aug 24, 2007 5:41 am

Post » Tue Jun 19, 2012 9:09 am

wait the script is in my forum messagebox of course:

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
if akSourceContainer == Game.GetPlayer()
akSourceContainer.MoveTo(MyMarker)
endIf
endEvent
ObjectReference Property MyMarker auto

(I got it from severed skullz btw, credit to him)

strange thing is: this script didn't work for days.. and then it just worked since 1-2 days ago, no idea why that is but now it works.
User avatar
David John Hunter
 
Posts: 3376
Joined: Sun May 13, 2007 8:24 am

Post » Mon Jun 18, 2012 8:51 pm

In non-global functions, such as the http://www.creationkit.com/OnActivate_-_ObjectReference event, there is a special variable called "Self" that points to the object on which the function is running.

If you're adding something to the player's inventory, then you'll need the base object so you'll have to use the result of calling http://www.creationkit.com/GetBaseObject_-_ObjectReference on "Self".

Cipscis
User avatar
Ridhwan Hemsome
 
Posts: 3501
Joined: Sun May 06, 2007 2:13 pm

Post » Tue Jun 19, 2012 11:44 am

In non-global functions, such as the http://www.creationkit.com/OnActivate_-_ObjectReference event, there is a special variable called "Self" that points to the object on which the function is running.

If you're adding something to the player's inventory, then you'll need the base object so you'll have to use the result of calling http://www.creationkit.com/GetBaseObject_-_ObjectReference on "Self".

Cipscis

Thanks!!! :)
Jashkar
User avatar
Eddie Howe
 
Posts: 3448
Joined: Sat Jun 30, 2007 6:06 am


Return to V - Skyrim