Container Dumping Script

Moderator: Event DM

Post Reply
User avatar
Jordicus
Team Member; Retired with Honors
Posts: 8042
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)
Contact:

Container Dumping Script

Post by Jordicus » Mon May 19, 2003 12:16 am

I have searched through many of the script libraries available and have not found anything like what I am searching for. I do not know if it even possible, so you guys tell me. I am not that good at scripting, so there is no way I could make it myself.

I would like to create a script that upon dropping a container (bag, box, magic bag, etc.) into a persistant chest, it would automatically dump the contents into the chest and give you back the empty bag. Obviously you would have to have enough free space to fit the contents of the bag, and the items would have to be non-stacking items since there is still a stacking issue with the persistant chests.

Currently, since there is a problem with putting full bags into persistant chests, the only way to put the contents of a bag into a chest is to remove each item, one at a time, from the bag, and then put each item, one-at-a-time into the chest. If such a script was possible, you would take your full bag, making sure there were no stackable items in it, plop the bag into the chest, the script would fire and empty the contents for you and you wuold get back an empty bag.

What do you think? Is this possible?
User avatar
j5hale3
Apprentice Scholar
Posts: 964
Joined: Tue Jan 14, 2003 3:23 am
Location: Central NJ {EST (GMT -5) and EDT (GMT -4)}

Post by j5hale3 » Wed Jun 04, 2003 3:18 pm

Please Gods of Scripting, say Yes.

After of a week of having a persistant chest to use, my mouse clicking hand is numb from the empty bag-->fill chest moves..

I do a lot of this just after crafting so I'm getting a double whammy.
User avatar
Aloro
Team Member; Retired with Honors
Posts: 12805
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End
Contact:

Post by Aloro » Wed Jun 04, 2003 5:46 pm

Let me see what I can do. I have a lot of other projects right now, but I'll take a poke at this when I get a little time.

- Aloro
User avatar
j5hale3
Apprentice Scholar
Posts: 964
Joined: Tue Jan 14, 2003 3:23 am
Location: Central NJ {EST (GMT -5) and EDT (GMT -4)}

Post by j5hale3 » Wed Jun 04, 2003 5:52 pm

Holds breath..........turns blue.......... passes out..........

Wakes up


Holds breath.............turns blue.............passes out........

Good luck!! Also I think someone from the AAAA is working on it too...

Thanks..

{edit} Throwing caution to the wind.... How about some way to fill a box from the "P" chest by selecting one item and dragging it to the box in a special way maybe a Left click or something. The effect I'm looking for is "fill this chest with iron ore please" then the chest will try to fill the box as best as possible.
Last edited by j5hale3 on Wed Jun 04, 2003 6:33 pm, edited 1 time in total.
User avatar
Nighthawk4
Assist DM
Assist DM
Posts: 25898
Joined: Fri Feb 07, 2003 8:32 pm
Timezone: GMT
DM Avatar: DruEl
Location: The Home of the Bard of Avon
Contact:

Post by Nighthawk4 » Wed Jun 04, 2003 6:27 pm

Excuse my ignorance, as I know nothing of scripting.

However, isn't this similar to what happens when we retrieve our Death Corpse - the contents are dumped back into our inventory?
Life is never as bad as you think it is, although that doesn't help at the time.
Orleron wrote:I think it's a fun idea if you can idiot-proof it. Problem is God always builds a better idiot. :P
User avatar
Aloro
Team Member; Retired with Honors
Posts: 12805
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End
Contact:

Post by Aloro » Wed Jun 04, 2003 6:33 pm

No, when you loot your corpse, items in containers remain in containers.

- Aloro
User avatar
Jordicus
Team Member; Retired with Honors
Posts: 8042
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)
Contact:

Post by Jordicus » Wed Jun 04, 2003 6:39 pm

yes and no...

in that case, all the contents of the corpse container are pulled back into your inventory, no questions asked...

this would be a little more specific... it would have to only activate upon dropping a container into a chest..

basically the script would be attached to the chest... on the OnDisturbed event and would have to check if the item dropped matched a certain criteria. If so, then the contents of the container would have to be moved into the chest. that is the real tricky part... you have to continually scan the container to see if it has more items in it.. and the move part would probably have to involve a creation/destruction sequence...

i know the basic concepts to do it, I just don't know enough about the cripting to pull it off
User avatar
j5hale3
Apprentice Scholar
Posts: 964
Joined: Tue Jan 14, 2003 3:23 am
Location: Central NJ {EST (GMT -5) and EDT (GMT -4)}

Post by j5hale3 » Wed Jun 04, 2003 6:39 pm

Aloro is right but the concept is very similiar.

Something to think about. Would the users of this function rather keep the container or have it also put in the "P" chest. I can see the value of either case.

Best regards.
User avatar
Sindol
Team Member; Retired with Honors
Posts: 6479
Joined: Mon Jan 06, 2003 4:23 pm
Location: Nijmegen - Netherlands (GMT+1)
Contact:

Post by Sindol » Wed Jun 04, 2003 6:58 pm

Also I think someone from the AAAA is working on it too...
Confirmed, although not entirely like it. He is working on mining bags: they only hold one item type (ore). Jordicus knows who I'm talking about.

The persistent chests in the guildhouses should be able to accept all ingredients that are delivered through a scripted conversation though. Maybe you can use that interface medium as well. Again: I have no idea how Myk did it, but it's grand.
So much fun,
yet so little time to enjoy it.
- Sindol
User avatar
Silk
Co-Founder
Posts: 6662
Joined: Fri Sep 14, 2001 6:47 pm
Contact:

Post by Silk » Wed Jun 04, 2003 7:51 pm

Here's some pseudo code:

Code: Select all

void function DumpContents(object oFrom, object oTo)
{
  object oItem = GetFirstItemInInventory(oFrom);

  while (GetIsObjectValid(oItem)){
    CopyObject(oItem, oTo);
    DestroyObject(0.0f, oItem);

    oItem = GetNextItemInInventory(oFrom);
  }
}

// The following code would go into the OnDisturved Added Event of the container

object oPlaceableContainer = OBJECT_SELF;
object oItemBox = GetLastItemDisturbed();  // This is pseudocode, forgot name of function
object oPlacer = GetLastDisturbed();

if (GetHasInventory(oContainer)){
  DumpContents(oItemBox, oPlaceableContainer);
  CopyObject(oItemBox, oPlacer);
  DestroyObject(0.0f, oItemBox);
}
Silk

Member of the MadK@t lover's group.
User avatar
Jordicus
Team Member; Retired with Honors
Posts: 8042
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)
Contact:

Post by Jordicus » Wed Jun 04, 2003 9:09 pm

Dude!!

now I can't wait to get home and play around with this... i am assuming it would work in combination with persistancy as well?
User avatar
Silk
Co-Founder
Posts: 6662
Joined: Fri Sep 14, 2001 6:47 pm
Contact:

Post by Silk » Wed Jun 04, 2003 9:15 pm

No. persistency would require some more code with regards to adding items to the database.
Silk

Member of the MadK@t lover's group.
Myk D'vor
Lord of Blithering Idiots
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

Post by Myk D'vor » Sun Jun 15, 2003 7:06 pm

Through several conversations with Fegall we came up with a slightly more comprehensive object for moving ore and ingots, I called it an Ore Shovel. It has yet to be added to the module, but I believe it's in the final stages of approval by Papillon. It has 4 functions, you choose between them in a conversation tree.

1) Shovel loose ore into your empty bags. This is limited to a medium amount of bags, and your strength increases the limit slightly, but it does just what it says. All loose ore in your inventory not already inside a container, gets stuffed into one, if you have any. The reason we decided to use only empty bags was to allow people to exempt some bags from consideration. If you only have 3 80% bags, and don't want to risk them in a forge with ore inside, you just put any non-ore object in them and they will be ignored. We did NOT use special mining bags, any container you have can be used.

2) Shovel ore from your inventory (including inside bags) into a nearby forge. This will walk you up to 15 meters to the nearest forge, and shovel all your ore into it. Yes, this does mean you can shovel 600+ ore with a single command. Just hope the server doesn't crash with all your ore in the forge ;) As for the illogical nature of being able to shovel 600 ore in a few seconds, see below...

3) Shovel finished ingots out of the forge into your now empty bags. Same reason as above, bags with anything in them other than ingots will be ignored.

4) Shovel ingots from your inventory (including inside bags) into a nearby anvil. Again, it will walk you up to 15 meters to the nearest anvil, and shovel all your ingots into it.

Now, this all sounds too good to be true, right? Right. The conversation warns you that this is not a safe operation, because you will be tremendously distracted and unable to react if you are attacked... The reason is because I take control away from the PC, and make them perform several appropriate animations. These animations take the time we decided would be appropriate for shovelling that much crap from one place to another. The time spent is a base time plus 1 second per 10 pieces moved, so it's obviously most efficient for large loads, and you're better off moving 5 rocks manually. For some humor at the end you make the tired animation and then drop into a dead sleep animation for a few seconds ;)

Myk
User avatar
j5hale3
Apprentice Scholar
Posts: 964
Joined: Tue Jan 14, 2003 3:23 am
Location: Central NJ {EST (GMT -5) and EDT (GMT -4)}

Post by j5hale3 » Sun Jun 15, 2003 7:38 pm

Can this "item" be expanded to allow movement of any of the crafting items from one container to another?

I currently deal with iron ore and ingots, ice crystals, fire potions, and wood. I need to store these items in my chest until needed. I don't mind the time penalty if it's about the same as doing it manually. I just get bored of {load box of raw material, move it to my storage area, unload box to personal inv, load persistant chest, later unload persistant chest to box in personal inv, move to crafting item, repeat from step 1 one click-drag at a time} I'd love to be able to "shift-Click-drag several items from one containger to another.

Thanks for the update.

J5hale3
Myk D'vor
Lord of Blithering Idiots
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

Post by Myk D'vor » Sun Jun 15, 2003 7:49 pm

I'm afraid not. There's way too many possibilities out there to plan for. I do agree that having a container dump its inventory into the persistent chest automagically would be the best solution possible.

The reason for the ore shovel is because the crafters deal with numbers of ore and ingots in an order of magnitude higher quantities than ANY other craft. To make most CR 5 weaponcrafting choices takes 15 ingots, which in turn was 30+ rocks of ore, each of which had to be moved at least 3 times, then the 15 ingots 2 more times, EACH.

We do have some things in the works to make crafting more user-friendly on the placeables themselves, but I shouldn't betray the confidence of Fegall, you'll have to wait and see. Meanwhile, the auto-dump of containers into the inventory of a persistent chest, AND having the chest store said contents persistently, would be a boon for just about ANYONE, and especially crafters.

Until then, my custom-made special storage chest, currently in live-testing in the T'Nanshi AAAA guildhall, will be helpful in storing items in quantity quickly and efficiently, organizing them, and allowing you to remove a specific item in quantity very quickly. I have struck a deal with the AKN to provide them with one or more of their own for their guildhall as well, so we can hope to see more convenience possible in the near future.

Myk
User avatar
j5hale3
Apprentice Scholar
Posts: 964
Joined: Tue Jan 14, 2003 3:23 am
Location: Central NJ {EST (GMT -5) and EDT (GMT -4)}

Post by j5hale3 » Sun Jun 15, 2003 7:53 pm

Definately Looking foward to the shovel!!!

Thanks!
User avatar
Vanor
Team Member; Retired with Honors
Posts: 8376
Joined: Thu Aug 15, 2002 7:46 pm
Location: Wisconsin (GMT -5)

Post by Vanor » Mon Jun 16, 2003 10:20 pm

I think I have a way, that could in theory work, to alow you to use the shovel to fill a persistent chest. But it would be tricky for serveral reasons.

Myk, if you did it like I think you did, with some sort of get object by tag command, you could tag a chest something like forge_orestorgeVanor or something. Then the shovel could be used to fill a persistent chest. If you wanted to... You could do one for ore and one for ingonts I suppose.

This is just theory on my part, since I don't know how Myk wrote the script. It's also a bit of a kludge, because it would require retagging all the chests out there which will not happen.

But even if it wouldn't work the shovel is a huge step ahead for making crafting less a pain in the wrist.
Myk D'vor
Lord of Blithering Idiots
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

Post by Myk D'vor » Tue Jun 17, 2003 1:21 am

You're right, that would work. It searches through all placeables in the area and finds one within 10 meters that has a tag that begins with "forge" or "anvil" (not case-sensitive), no matter what comes after that. I'm not positive that the persistent chest would fire the OnDisturbed event properly to add all the objects to the database, but the Shovel would definitely fill it with ore or ingots if you tricked it in this way. It would even allow you to empty the fake-forge chest of ingots, but you'd have to have manually put them in there in the first place.

Another option is to allow me to sell my invention of the custom special storage chest (persistent), which allows for quick-fill and quick-empty of up to 100 objects at a time, literally millions of objects possible, including stackables. It even organizes them for you, and lets you access them from a conversational list of item types, 10 per page, with no foreseeable upper limit (over a million types, and over a million of each type possible to be stored). The only drawback to it is that it's slightly less intuitive than Silk's chest, and isn't visual, you have to know what you're putting in or taking out. This chest was my solution to the lag that was always a problem before Silk put in the delay to fill the persistent chests the first time you open them, and it's still much faster.

Myk D'Vor
User avatar
Jordicus
Team Member; Retired with Honors
Posts: 8042
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)
Contact:

Post by Jordicus » Wed Jun 18, 2003 11:48 pm

ok.. I took the pseudocode version that Silk posted and worked out all but 1 kink

Code: Select all

1  void DumpContents(object oFrom, object oTo)
2  {
3   object oItem = GetFirstItemInInventory(oFrom);
4
5   while (GetIsObjectValid(oItem))
6   {
7     CopyObject(oItem, GetLocation(oTo), oTo);
8     DestroyObject(oItem, 0.0f);
9     oItem = GetNextItemInInventory(oFrom);
10  }
11 }
12
13
14 // The following code would go into the OnDisturbed Added Event of the container
15 void main()
16 {
17 object oPlaceableContainer = OBJECT_SELF;
18 object oItemBox = GetInventoryDisturbItem(); 
19 object oPlacer = GetLastDisturbed();
20 
21 if (GetHasInventory(oPlaceableContainer))
22   {
23   DumpContents(oItemBox, oPlaceableContainer);
24   CopyObject(oItemBox, GetLocation(oPlacer), oPlacer);
25   DestroyObject(oItemBox, 0.0f);
26   }
27 }
Everything is working but the removing of the items from the original bag (Line 8). Code seems right. Any ideas?
Myk D'vor
Lord of Blithering Idiots
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

Post by Myk D'vor » Thu Jun 19, 2003 11:29 pm

The problem is actually line 24. Destroys of objects wait until the script is complete, so they still exist inside the bag when line 24 is executed, and it copies the bag, contents and all. What you are better off doing is a CreateItemOnObject of a new bag, same resref, but it will be empty. It's either that or delay the exectution of the line 24-> code until after the Destroys have finished.

Myk D'Vor
User avatar
Jordicus
Team Member; Retired with Honors
Posts: 8042
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)
Contact:

Post by Jordicus » Fri Jun 20, 2003 2:12 am

ok.. got it and it is working perfectly...

Code: Select all

void DumpContents(object oFrom, object oTo)
{
  object oItem = GetFirstItemInInventory(oFrom);

  while (GetIsObjectValid(oItem))
  {
    CopyObject(oItem, GetLocation(oTo), oTo);
    DestroyObject(oItem, 0.0f);

    oItem = GetNextItemInInventory(oFrom);
  }
}

// The following code would go into the OnDisturbed Event of the container
void main()
{
object oPlaceableContainer = OBJECT_SELF;
object oItemBox = GetInventoryDisturbItem();
object oPlacer = GetLastDisturbed();
string sNewBox = GetTag(oItemBox);

if (GetHasInventory(oPlaceableContainer))
{
  DumpContents(oItemBox, oPlaceableContainer);
  DestroyObject(oItemBox, 0.0f);
  SetIdentified((CreateItemOnObject(sNewBox, oPlacer)),TRUE);
}
}
Thanks to Silk for the original pseudocode!!

Now, for use with persistant containers, this code could easily be changed to an external function and then added to the "pcont_disturbed" script used for persistent containers.

I think you could add it into the code:

Code: Select all

case INVENTORY_DISTURB_TYPE_ADDED:
            ** insert call to function here **
            addItem(GetTag(OBJECT_SELF), oItem);
        break;
I only see two potential problems. What if the bag contains stacked items? I don't think the stackable items checker would catch them inside a bag. IT could be adjsuted to reject a bag that had stacked items in it. that would simplify the issue. The other potential problem is what if the chest is full? From what I understand, there can only be 20 pages to a chest? How would the code know if the chest could or could not hold the additional items...???

any suggestions?
Myk D'vor
Lord of Blithering Idiots
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

Post by Myk D'vor » Fri Jun 20, 2003 4:00 pm

What we really need next is a test of the OnDisturbed event. Put some debugging type messages in a quick script in the OnDisturbed event of your test chest, to see if the event fires for each item inside the bag as it's copies to the chest inventory or not. I -think- it will, in which case most of this issue is solved. The only snag I foresee in that case is in the case of stackables, where it is trying to return the object to the original owner, I'm not sure how exactly it retrieves that information, if it is set properly or not when a bag object is copied into it. It may set it to be the BAG as the original owner, which could be worked around, but wouldn't work to start. I suggest you simply add this to OnDisturbed:

Code: Select all

SpeakString("Item with tag = "+GetTag(item)+" added by owner "+GetName(oPC));
This will give some useful feedback for when it fires. Test it with a bag with 3-5 objects, including one stackable, to start, then later try 3 separate stacks of 1 matching scroll, which will probably fire the OnDisturbed only once, if at all.

Unfortunately I don't have access to the Toolset while I'm on vacation or I'd be doing some of this testing myself out of curiousity ;)

Myk D'Vor

P.s. The limit is 25 pages displayed. I believe any items stored beyond that limit will be there, just not retrieveable. If you empty out some of the storage and let the server reset, the next time the inventory loads for the user it will include the stuff that couldn't fit the first time.
Last edited by Myk D'vor on Fri Jun 20, 2003 4:19 pm, edited 1 time in total.
User avatar
j5hale3
Apprentice Scholar
Posts: 964
Joined: Tue Jan 14, 2003 3:23 am
Location: Central NJ {EST (GMT -5) and EDT (GMT -4)}

Post by j5hale3 » Fri Jun 20, 2003 4:09 pm

As a new inductee to the AAAA, I would like to send a big thank you to the scripters of the storage items in the guild, and the shovel. These are two big helps. You guys deserve a medal.

And, I can stop holding my breath!

This is really great!

Best regards,

J5hale3
Post Reply