Author Topic: Creating a container inside another container  (Read 551 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Creating a container inside another container
« on: April 05, 2011, 05:49:13 am »


                How do you create two containers and put one inside the other via script?

Obviously this does not work

object oPC = GetPCSpeaker();
object oPackage = CreateItemOnObject("package", oPC);
object oGoblinBox = CreateItemOnObject("goblinbox", oPackage);

               
               

               


                     Modifié par henesua, 05 avril 2011 - 04:50 .
                     
                  


            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
Creating a container inside another container
« Reply #1 on: April 05, 2011, 06:12:41 am »


               what is below this but replace "tag of the recieving container" with the tag of the recieving container and replace "resresf of the container you want to create in the recieving container" with the resref of the container you want to create in the recieving container

Edit: that would create one 1 container inside another but you have to specify where you want the recieving container to be created for the complete script this is just a half solution

void main()
{

object oTarget;
oTarget = GetObjectByTag("tag of the recieving container");

CreateItemOnObject("resresf of the container you want to create in the recieving container", oTarget);

}
               
               

               


                     Modifié par Ryuhi2000, 05 avril 2011 - 05:16 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Creating a container inside another container
« Reply #2 on: April 05, 2011, 06:32:08 am »


               Based on what you wrote the following should work:

[color="#00ff00"]object oPC = GetPCSpeaker();
CreateItemOnObject("nw_it_contain006", oPC);
object oPackage = GetObjectByTag("NW_IT_CONTAIN006");
object oGoblinBox = CreateItemOnObject("goblinbox", oPackage);[/color]

It does not. There is nothing magical happening with GetObjectByTag that enables a container to receive another from CreateItemOnObject.

[EDIT]
I just realized that I did not specify that both containers are items. I think this is a hard coded limitation of NWN which forbids nestinf of container items.
               
               

               


                     Modifié par henesua, 05 avril 2011 - 05:44 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Creating a container inside another container
« Reply #3 on: April 05, 2011, 06:46:11 am »


               Inventory containers can not be placed into other inventory containers. : (
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Creating a container inside another container
« Reply #4 on: April 05, 2011, 07:13:25 am »


               Not 100% sure what your reasons are for doing this but there are other types of packaging options that you could do. Like if you wanted a package that will only be opened once..like a gift..to have a container as the gift..you could just make the package a non container item that would be activated(opened) and then the container gift would be created in the players inventory. And then the gift package could be replaced by an actual container duplicate so the player would have 2 containers at that point.

Just throwing ideas out.
               
               

               


                     Modifié par GhostOfGod, 05 avril 2011 - 06:16 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Creating a container inside another container
« Reply #5 on: April 05, 2011, 08:04:23 am »


               GOG - thanks. what you mention as your first option is how I initially conceived doing this, but I preferred the two container solution. And yes it is a wrapped gift. '<img'>
               
               

               


                     Modifié par henesua, 05 avril 2011 - 07:05 .
                     
                  


            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
Creating a container inside another container
« Reply #6 on: April 05, 2011, 01:19:10 pm »


               you just need 2 objects (oPC and 1 other)  for the script you posted not 3 total objects

henesua wrote...

Based on what you wrote the following should work:

[color="#00ff00"]object oPC = GetPCSpeaker();
CreateItemOnObject("nw_it_contain006", oPC);
object oPackage = GetObjectByTag("NW_IT_CONTAIN006");
object oGoblinBox = CreateItemOnObject("goblinbox", oPackage);[/color]

It does not. There is nothing magical happening with GetObjectByTag that enables a container to receive another from CreateItemOnObject.

[EDIT]
I just realized that I did not specify that both containers are items. I think this is a hard coded limitation of NWN which forbids nestinf of container items.


this script wont work exactly  for your needs but it will work closely to them. it creates the would be gift in a placeable in the area the player is in. the player would then have to go open the placable to get the item....
 
void main()
{

object oPC = GetPCSpeaker();

object oArea = GetArea(oPC);

object oTarget = GetItemPossessedBy(oArea, "tag of the recieving placable in the area");

CreateItemOnObject("resresf of item to go in the placable", oTarget);

}
               
               

               


                     Modifié par Ryuhi2000, 05 avril 2011 - 12:47 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Creating a container inside another container
« Reply #7 on: April 05, 2011, 04:43:01 pm »


               Ryuhi, what exactly does this accomplish? We are still unable to create a container item nested inside another container item. GOG confirmed my suspicion that it is a hard coded limitation.

In game it is also not possible for a PC to place one container item inside another's inventory. I was just hoping for a way around this. But I recognize now how far fetched that is.
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
Creating a container inside another container
« Reply #8 on: April 05, 2011, 08:51:44 pm »


               i was mealy suggesting you script put the item you want to be the gift in the placeable in the area and have the player get the item that way

edit: here is my exact quote for that "this script wont work exactly  for your needs but it will work closely to them. it creates the would be gift in a placeable in the area the player is in. the player would then have to go open the placable to get the item...."
               
               

               


                     Modifié par Ryuhi2000, 05 avril 2011 - 07:53 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Creating a container inside another container
« Reply #9 on: April 05, 2011, 10:14:58 pm »


               I also like GoG  do not have enough information on what you are trying to do.

Ok, there is no way to have both of them as Items that have inventories.  The way around this is to make one of them an item with an unique power.  Set the unique Power up to create an invisible placeable by the PC. then create the items that it contains into the placeable   and give the PC an action to open the placeable. On close of the placeable have it  save its inventory and destroy itself. This will give the illusion that the Item itself has an inventory.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Creating a container inside another container
« Reply #10 on: April 05, 2011, 10:43:14 pm »


               Lightfoot - I've explained it all above. I appreciate the help, but as I said above your solution is one that I had already considered and since it is apparently the best option I am pursuing it.

The only thing that really pertains to this thread is my request for nesting container items. Since that is not possible, I have my answer. Thanks.
               
               

               


                     Modifié par henesua, 05 avril 2011 - 09:44 .