Using GetSelf in a script attached to a container.

Post » Fri May 27, 2011 1:48 pm

And if so, should it be possible to use AddItem to add something to it, as a sort of dynamic container. And also, will the script be reset when the object is reset?
User avatar
Scarlet Devil
 
Posts: 3410
Joined: Wed Aug 16, 2006 6:31 pm

Post » Fri May 27, 2011 4:34 pm

All of the following is based on my assumption that nothing relevant has changed from how it worked in Fallout 3 (please let me know if something has)...

If you want to use http://geck.gamesas.com/index.php/AddItem to add an item to a reference to a scripted object from within that object's script, you don't need to use http://geck.gamesas.com/index.php/GetSelf. The following two segments of code will do the same thing, except the script that uses http://geck.gamesas.com/index.php/GetSelf will be slightly slower and will not work if the placed reference is saved in the savegame, like one that was placed via http://geck.gamesas.com/index.php/PlaceAtMe:
ref rSelf;...set rSelf to GetSelfrSelf.AddItem ExampleItem 1
AddItem ExampleItem 1

To answer the question you asked in the title, http://geck.gamesas.com/index.php/GetSelf will return the container's refID, except in the case that it is saved in the save file (i.e. starts with 0xFF, and as opposed to being saved in a data file) where it will instead return 0. http://geck.gamesas.com/index.php/GetSelf is only useful when that information is passed to an external script, or it is needed for a function parameter, such as with http://geck.gamesas.com/index.php/PushActorAway.

Cipscis
User avatar
Courtney Foren
 
Posts: 3418
Joined: Sun Mar 11, 2007 6:49 am

Post » Fri May 27, 2011 10:43 pm

Alright, I will unfortunately be having to have scripts like this attached to a lot of containers in my mod, because basically as days pass in the game, the world changes, and things become more scarce. So none of these containers are in the savegame, they'll all be placed already in the mod. Just having a script attached to each container like this:

if GameDaysPassed < 2AddItem blahblah 1endifif GameDaysPassed >= 2AddItem blwhblwh 1 endif


Will work fine? I'm not sure which block type to use for this though, because I only want it to happen once, when the container is first loaded, but I'm not sure if using a "doOnce" variable thing will work if the cells containing the containers respawn, you know what I mean?
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am

Post » Fri May 27, 2011 4:52 pm

Script variables will remain persistent in regular gameplay, so if you use a "doOnce" variable in, say, an http://geck.gamesas.com/index.php/OnLoad block, then the code you want to run should only run once when the reference is first loaded.

Cipscis
User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm


Return to Fallout: New Vegas