You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When utilizing swapItems hook you are unable to modify the item metadata. This prevents some interesting use cases such as modifying an items durability upon placing into a container or performing some other function such as drying materials.
Describe the solution you'd like
The ability to modify metadata as part of the swapItem hook. Currently you can only return true or false to permit/deny the swapItems action. Ideally this would be accomplished by appending a table of metadata to the end of the swapItems return and have this applied to the item once it arrives in the destination inventory.
Describe alternatives you've considered
Modifying the swapItems code directly to add functions for specific items but this is inflexible and error prone.
Additional context
One resource that modifies the swapItems function as part of the installation steps is rep-weed. The code they add into the function looks like below. If it was possible to modify the metadata via hook then this would no longer be required.
if fromData.name == 'wetbud' then
if fromInventory.type == 'stash' then
if fromInventory.type == 'stash' then
if not fromData.metadata then
fromData.metadata = {}
fromData.metadata.time = os.time()
fromData.metadata.dry = 10
else
if not fromData.metadata.time then fromData.metadata.time = os.time() end
if not fromData.metadata.dry then fromData.metadata.dry = 10 end
end
end
end
end
end
fromInventory.items[data.fromSlot] = fromData
if toData then
if toData.name == 'wetbud' then
if toInventory.type == 'stash' then
print('stash')
if not toData.metadata then
toData.metadata = {}
toData.metadata.time = os.time()
toData.metadata.dry = 10
else
if not toData.metadata.time then toData.metadata.time = os.time() end
if not toData.metadata.dry then toData.metadata.dry = 10 end
end
end
end
end
toInventory.items[data.toSlot] = toData
Yes the above code is terrible and I didn't write it
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When utilizing swapItems hook you are unable to modify the item metadata. This prevents some interesting use cases such as modifying an items durability upon placing into a container or performing some other function such as drying materials.
Describe the solution you'd like
The ability to modify metadata as part of the swapItem hook. Currently you can only return true or false to permit/deny the swapItems action. Ideally this would be accomplished by appending a table of metadata to the end of the swapItems return and have this applied to the item once it arrives in the destination inventory.
Describe alternatives you've considered
Modifying the swapItems code directly to add functions for specific items but this is inflexible and error prone.
Additional context
One resource that modifies the swapItems function as part of the installation steps is rep-weed. The code they add into the function looks like below. If it was possible to modify the metadata via hook then this would no longer be required.
Yes the above code is terrible and I didn't write it
The text was updated successfully, but these errors were encountered: