I’m looking for a way to create a Leomund chest spell.
So I would like to create a script teleporting this placeable chest to PC when he uses the summoning scroll, and teleporting the chest back to its “hidden limbo” location OnClosing it.
How to use the Jump command with a placeable?
Being new member, I apologies if this question has already been ask on forum (using a fast research I did not find any topic related- or I have to take more time to handle this forum)
Incidentally, the Lexicon entry for CopyItem() is quite helpful in identifying the special cases that need to handled e.g. item variables, containers and plot items.
In that case I still have a problem to set the sell/buy to zero, a 1 gold piece remains when I edit a custom merchant)
for me, there seems not to be a workaround around this problem. The max buyprice to 1g is easiely set, but you can’t control the maximum sell price in the same way.
I see what you’re trying to do there - it’s the only inventory you can open remotely - but I don’t think you can work around the 1gp snag and other merchant biz.
The method I described works. Normally, it’s used to move inventories from creatures to containers, and vice-versa, which is why it has to go item-by-item. Not difficult to script.
If you’re looking for a simpler method in this special case, how about this?
CopyObject to create a copy of the chest at the PC’s location with bCopyLocalState=TRUE, then destroy the original chest
Let the PC open the chest and change the inventory
OnClose, copy the new chest to the old location before destroying it
I’ve verified that this works for a mixed inventory including gold, containers with contents, plot items, stolen items and item local variables.
There are ways to copy the inventory of the chest to another object and destroy the original. The trick is making sure everything copies over. Bags inside the chest with their own inventory need to have the bag copied and then each object inside copied to the new bag before moving on.
I have seen it done a few ways. Long ago, I started using a script from the Killer Death System called “_move_inv_inc” which handles this well (the function is called MoveEverything).
This may be something ancient and long-since fixed, but I recall items inside other items (bags…) had issues.
This is from the lexicon: If you are iterating through a dead PC’s inventory and use CopyObject() on a container that has items within it, and copying to another placeable (a Corpse placeable for example) the items are duplicated. This occurs because the items belong both to the parent container and again to the child container. It may be possible to get around this unexpected behavior by marking each item already processed using SetLocalInt(), then seeing if an int value set exists on the item; if so do not copy the item (of course items in a copied object’s inventory will have to be iterated through manually).
True, but a different case. Testing today (in EE), CopyObject on a placeable containing a bag of items results in a placeable containing an identical bag of items.