Preserving item meta data in stacks

User avatar
y.st.
Member
 
Posts: 38
Joined: Fri Mar 20, 2015 01:24
GitHub: y-st
IRC: Yst
In-game: Yst

Preserving item meta data in stacks

by y.st. » Thu Jun 18, 2015 19:56

When a player picks up an item that has meta data, that meta data is lost if the player has a stack of the same item in inventory, with the new item taking on the same meta data as the rest of the existing stack. Is there a way to prevent this without making that type of item completely unstackable? Specifically, if it would be useful to be able to stack all of said item with meta data set to "A" with others of the same item with the meta data set to "A", but have it be impossible to stack them with items with different meta data, for example, a stack of the same item with the meta data set to "B". Is there a way to acomplish this?

If it helps for context, my goal is to preserve the names attached to bones when they are harvested, allowing them to act as trophies. You might have a stack of thirty bones from PlayerA, but you don't want that to mostly fill a chest; you'd want them to only take up one inventory slot in the chest.
 

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

Re: Preserving item meta data in stacks

by SegFault22 » Fri Jun 19, 2015 01:03

It might be possible to make items with the same (exact) metadata stack together, however I don't know what kind of modifications would have to be done to the c++ part of the engine, for it to be handled properly. It may be possible to "store" items with differing metadata, in the metadata of a single (separate) item (table, maybe?) - however, since it would be a stack of one separate item, with metadata representing items "stacked" in it, there would need to be figured out some way to display a number for the total of items "stored" in the metadata of the "stack" item, and disallow stacking of the item more than once, because doing so would copy the metadata representing separate items, which would allow for duplication, by means of adding an (mostly) empty "stack"-item to one filled with the items one wishes to duplicate (in-game).

If stacks were handled with tables, we would be able to get around this problem completely - each individual item in a stack would be assigned its' own entry into the table (including the metadata), so items with different metadata would not automatically take on the metadata of the whole stack. However, this would result in stacks of items with identical metadata repeating the same line an unnecessary number of times - so, another column would be needed in the stack table, representing the number of items there are in the stack with the same metadata (for the stackstring/"ID" of the item).
 

User avatar
y.st.
Member
 
Posts: 38
Joined: Fri Mar 20, 2015 01:24
GitHub: y-st
IRC: Yst
In-game: Yst

Re: Preserving item meta data in stacks

by y.st. » Fri Jun 19, 2015 19:26

Yeah, that duplication is one of the main things I'm worried about. I might be able to run some custom Lua when this type of node is mined or otherwise retrieved, which might be able to separate the items by meta data, but a player could afterwards just manually merge the stacks in inventory. I'm not looking to merge item stacks with differing meta data though, as like you said, it would require changing the format items are saved in, making the format mor complex.

So making this work would require engine modifications? I was afraid that was the answer. I'll take a look at the code, but I don't know C++ yet, so I doubt I can get very far.

Thanks for the advice!
 

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

Re: Preserving item meta data in stacks

by SegFault22 » Sat Jun 20, 2015 00:16

There may be a way for it to be possible without modifying the c++ part of the engine, but I doubt it because the behaviour of stacks suggests that the implementation is too simple to handle stacking items by the item's id and the metadata. Someone who built the code could probably explain better how it won't work for this without being modified.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron