DJPaul Posted April 30, 2015 Share Posted April 30, 2015 Hello; I am new to modding DST and would appreciate advice from experienced developers. I have a situation where I need to swap the position of two inventory items. For example, on the player's screen, they have an item in each of the two left-most inventory slots. The item in slot 1 needs to be moved to slot 2, and the item that was in slot 2, needs to move to slot 1. What's the best way to do this? I'm hoping there's a built-in function that will get me close. I've found Inventory:GiveItem() which looks about right, though if it is the correct function, I am not yet familiar enough with Lua to understand if it will swap the inventory items' positions non-destructively, or whether it's going to spawn new items. Link to comment Share on other sites More sharing options...
Mobbstar Posted May 1, 2015 Share Posted May 1, 2015 First of all, this is the DS modding section. You're more likely to get useable code in the DST one. The function you mentioned gives an existing item to that inventory. Which means you need to get a reference to that specific item you want to swap.I suggest you use inventory:RemoveItem(item, wholestack) before though, to assure the item gets removed from the original owner. Link to comment Share on other sites More sharing options...
DJPaul Posted May 1, 2015 Author Share Posted May 1, 2015 Ah, sorry about posting on the wrong forum section. Doh! Thanks for the tip, I'll give it a go. Link to comment Share on other sites More sharing options...
Seiai Posted May 1, 2015 Share Posted May 1, 2015 @DJPaul, just look in the component inventory.lua, theres a lot of functions there and u can see how exactly it uses all the parameters. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.