Aller au contenu

Photo

How do you xfer items from another area?


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
nn125

nn125
  • Members
  • 42 messages
This question is based on the numerous mods to dump a container in the player camp that can be used for storage.

Now the barmy part - When you relocate to Denerim why would you leave the chest in the camp?

So how can you access an object in an older area from your current area to transfer the inventory?

#2
sillyrobot

sillyrobot
  • Members
  • 171 messages
The short answer is you can't. The area is removed from memory and stored on disk. Any objects in the area aren't available until the player returns to the area.



One area is excepted from this; char_stage is always in memory. However char_stage is not saved during a save game and any items in that location are missing from a re-load.


#3
nn125

nn125
  • Members
  • 42 messages
Could you bung everything in a Local Variable - Actualy how do they work? Esp the Local Object


#4
sillyrobot

sillyrobot
  • Members
  • 171 messages
I tried to use a Local Object as part of the bag of holding mod initally, but the object is really a reference or pointer and that didn't survive the are change or save/reload processes either. There are two techiniques that I know of to accomplish "remote" storage.



The first is demonstrated by the add-in "The Mysterious Bag", the second is demonstrated by "Bag of Holding". Both addins are available on this site and dragonagenexus.com. (The Bag of Holding is updated more recently on dragonagenexus.com. I ran into trouble with the site when I was doing the last update and haven't gone back to update this site.)



As I understand it, the Mysterious Bag overrides the exit area event to shift the store to char_stage and catches the enter area event to shift the store to the player locale. Thus the store is always with the player and never suffers potnetial loss.



The Bag of Holding I know much more about. It moves the store to the char_stage area and catches the presave event to move the store to the player's locale for the save event. This avoids overriding events, but requires more careful programming because if the bag is stranded in char_stage during a save, a load from that save will break the bag.



I suppose it might be possible to build the functions and store the inventory in local objects, but I expect that would get unwieldy very quickly. You'd have to write your own inventory sub-system to handle additions/deletions/stack updates and catch every changeable attribute in order to rebuild the item into an object as it leaves the local object storage.




#5
nn125

nn125
  • Members
  • 42 messages
I tried messing with char_stage, but struggled to grab a valid object



object oSA = GetObjectByTag("char stage") always returns an invalid object



So how do you get hold of it



Thanks in advance

#6
sillyrobot

sillyrobot
  • Members
  • 171 messages
It looks fine except you're missing an underscore.



object oSA = GetObjectByTag("char_stage");



My add-in includes source code as text files in addition to the erf package. Grab the latest (0.9) version. It is stable and demonstrates the techniques for using char_stage.

#7
nn125

nn125
  • Members
  • 42 messages
I tried to grab them but they are an NSS file and cant be open (even by the toolkit -> Can't find editor....


#8
nn125

nn125
  • Members
  • 42 messages
Sorry for being a pain but could you check the following script
When Ran with a param of 1 it creates the chest no probs

When ran again iVal =2 - It gets a valid area but returns an empty array

void main()
{
    string sVar     =  GetLocalString(GetModule(),"RUNSCRIPT_VAR");
    int nFind       =  FindSubString(sVar," ");
   string sVal      =  SubString(sVar,0,nFind);
    int    iVal      =  StringToInt(sVal);
    object oPC = GetHero();

    DisplayFloatyMessage(oPC, "Doing It", FLOATY_MESSAGE, 16777215, 10.0);


    if (iVal == 1) {
        object oSA = GetObjectByTag("char_stage");
        if(IsObjectValid( oSA ))
        {
            DisplayFloatyMessage(oPC, "Valid Area", FLOATY_MESSAGE, 16777215, 10.0);
            vector vUnsafePos = Vector( 0.0, 0.0, 0.0 );
            location lSL = Location( oSA, vUnsafePos, 0.0 );
            lSL = GetSafeLocation( lSL );
            object oChest = CreateObject( OBJECT_TYPE_PLACEABLE, R"pups_pla_cousland_chest.utp", lSL );
            if(IsObjectValid( oChest )) {
                DisplayFloatyMessage(oPC, GetTag(oChest), FLOATY_MESSAGE, 16777215, 10.0);
            } else {
                DisplayFloatyMessage(oPC, "InValid Chest", FLOATY_MESSAGE, 16777215, 10.0);
            }
        } else {
            DisplayFloatyMessage(oPC, "Not a Valid Area", FLOATY_MESSAGE, 16777215, 10.0);
        }  
    }
    if (iVal == 2) {        
        object oSA = GetObjectByTag("char_stage");
        if(IsObjectValid( oSA ))
        {
            DisplayFloatyMessage(oPC, "Valid Area", FLOATY_MESSAGE, 16777215, 10.0);
            object[] oSOs = GetObjectsInArea(oSA, "pups_pla_cousland_chest");
            int size = GetArraySize(oSOs);
            if (size > 0) {
                DisplayFloatyMessage(oPC, GetName(oSOs[0]), FLOATY_MESSAGE, 16777215, 10.0);
            } else {
                DisplayFloatyMessage(oPC, "Bad Chest", FLOATY_MESSAGE, 16777215, 10.0);
            }
        }
    }
           
}

#9
sillyrobot

sillyrobot
  • Members
  • 171 messages

nn125 wrote...

I tried to grab them but they are an NSS file and cant be open (even by the toolkit -> Can't find editor....


.NSS files are straight text -- you can use notepad or any other text editor.

#10
sillyrobot

sillyrobot
  • Members
  • 171 messages
As for the code, set the tag after creating the chest to the string you plan on searching for. I expect pups_pla_cousland_chest isn't the tag.