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 https://forums.kleientertainment.com/forums/topic/53384-swapping-items-positions-within-the-players-inventory/ 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 https://forums.kleientertainment.com/forums/topic/53384-swapping-items-positions-within-the-players-inventory/#findComment-633583 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 https://forums.kleientertainment.com/forums/topic/53384-swapping-items-positions-within-the-players-inventory/#findComment-633594 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 https://forums.kleientertainment.com/forums/topic/53384-swapping-items-positions-within-the-players-inventory/#findComment-633731 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now