ref.GetContainer not working?

Post » Fri May 27, 2011 8:22 am

Example:

ref SomeREFBegin OnActivate		set SomeREF to Thingy.GetContainer		SomeREF.AddItem OtherThingy 1end	



Thingy here is a persistent reference. SomeREF ends up being equal to 0. Known issue? Something else I'm messing up?
User avatar
Causon-Chambers
 
Posts: 3503
Joined: Sun Oct 15, 2006 11:47 pm

Post » Fri May 27, 2011 7:33 am

What kind of object are you attaching the script to? The onactivate block won't fire if it's an ingestible.
User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am

Post » Fri May 27, 2011 12:29 pm

Example:

ref SomeREFBegin OnActivate		set SomeREF to Thingy.GetContainer		SomeREF.AddItem OtherThingy 1end	



Thingy here is a persistent reference. SomeREF ends up being equal to 0. Known issue? Something else I'm messing up?


When an object is placed into a container, it no longer holds a REF name.

I'm confused as to exactly what's going on, here.

I've never used getcontainer in this way. What is it you are trying to do, exactly?
User avatar
Terry
 
Posts: 3368
Joined: Mon Jul 09, 2007 1:21 am

Post » Fri May 27, 2011 12:10 pm

When an object is placed into a container, it no longer holds a REF name.

I'm confused as to exactly what's going on, here.

I've never used getcontainer in this way. What is it you are trying to do, exactly?


Well, that would explain it then. The item doesn't even know itself. Hmm.

For simplicity's sake, what I'm doing is pretty much the example. Thingy can be put in a container by the player. I want to know what container it is in, and then have whatever container that is gain an item when an activator is triggered. It seems this will be rather more difficult than I thought.
User avatar
Cody Banks
 
Posts: 3393
Joined: Thu Nov 22, 2007 9:30 am

Post » Fri May 27, 2011 12:00 pm

Well, that would explain it then. The item doesn't even know itself. Hmm.

For simplicity's sake, what I'm doing is pretty much the example. Thingy can be put in a container by the player. I want to know what container it is in, and then have whatever container that is gain an item when an activator is triggered. It seems this will be rather more difficult than I thought.


IF and only if the container is in the player's loaded area (same cell if it is an interior) when the activator is triggered, it is possible

it would be like this. See if it works, anyway.

You make your activator one whose base definition you created, and you give it a REF name, and a script. So lets say its MyActivatorREF. You put this script on the base object.

scn MyActivatorSCRIPTshort CompletelyActivatedbegin onactivate     if isactionref player          set CompletelyActivated to 1     endifend


Then, the Thingie has this script living on it.

scn ThingieSCRIPTref MyselfREFbegin onadd     set myselfREF to getcontainerendbegin gamemodeif MyActivatorREF.CompletelyActivated     MyselfREF.additem AllTheHappyNewItems     removemeendifend


I think that does what you want, you could try it and see. But like I said, forget it if the player's not in the room with the container which has Thingie in it when the activation happens.
User avatar
Danny Warner
 
Posts: 3400
Joined: Fri Jun 01, 2007 3:26 am

Post » Fri May 27, 2011 7:30 pm

Thanks, Tarrant.

The way around turned out to be just as easy as the way I originally wanted to do. I think. I thought it was odd that the persistent ref could still run scripts itself just fine in a container but I couldn't make it do functions from another script. No big deal in the end though.
User avatar
Casey
 
Posts: 3376
Joined: Mon Nov 12, 2007 8:38 am


Return to Fallout: New Vegas