IcyTheWhite Posted February 27, 2015 Share Posted February 27, 2015 Hey, Icy here again..So after playing the game for a while, I've noticed that when you unequip a weapon by equipping something else, it tries to put that weapon in the last place, it has been before equipping, rather then just simply swapping it. This often makes my inventory quite messy and it's really frustrating to sort it over and over again. Now, I don't know how to create this mod by myself, so I'm asking for your help.Could anyone please make this little mod, that would instead of doing what I mentioned above, simply just SWAP the weapons (and tools) instead? It would be really, really helpful! Link to comment Share on other sites More sharing options...
Blueberrys Posted February 27, 2015 Share Posted February 27, 2015 @IcyTheWhite Try this code.AddSimPostInit(function(inst) local old_Equip = inst.components.inventory.Equip function inst.components.inventory:Equip(item, old_to_active) local eslot = item.components.equippable.equipslot local olditem = self.equipslots[eslot] if olditem ~= item then olditem.prevslot = self:GetItemSlot(item) end return old_Equip(self, item, old_to_active) endend)- You might also wanna check out this Sort Inventory mod. Link to comment Share on other sites More sharing options...
IcyTheWhite Posted February 28, 2015 Author Share Posted February 28, 2015 Hey, thanks for helping me out again, I appreciate that.But the mod crashed, when I tried to craft an axe.. Link to comment Share on other sites More sharing options...
Blueberrys Posted February 28, 2015 Share Posted February 28, 2015 @IcyTheWhite Log please. Link to comment Share on other sites More sharing options...
Corrosive Posted February 28, 2015 Share Posted February 28, 2015 @IcyTheWhite, You need to check if there actually was an old item before attempting to compare it. if olditem and olditem ~= item then Link to comment Share on other sites More sharing options...
Blueberrys Posted March 1, 2015 Share Posted March 1, 2015 You need to check if there actually was an old item before attempting to compare it. if olditem and olditem ~= item then I don't think that's the issue. If olditem is nil, then it would be "(nil) ~= item". As far as I know, that's perfectly fine, and will evaluate to false.See below. Link to comment Share on other sites More sharing options...
Corrosive Posted March 1, 2015 Share Posted March 1, 2015 @Blueberrys, That's the problem, olditem ~= item returns true when nil ~= item since nil is in fact not equal to item. (in contrast to languages that will either always return false or null when a nil/null is used in a comparison) Link to comment Share on other sites More sharing options...
Blueberrys Posted March 1, 2015 Share Posted March 1, 2015 @Corrosive Sorry, my mistake. I misunderstood. Thanks for clarifying, I see your point. Link to comment Share on other sites More sharing options...
IcyTheWhite Posted March 1, 2015 Author Share Posted March 1, 2015 Tested is out and now it works just fine.Thank you so much! This is what I was looking for. If you won't mind, I can make it an icon and put it on workshop (and credit you as well)... Link to comment Share on other sites More sharing options...
Blueberrys Posted March 1, 2015 Share Posted March 1, 2015 @IcyTheWhite Sure, go ahead. Link to comment Share on other sites More sharing options...
IcyTheWhite Posted March 1, 2015 Author Share Posted March 1, 2015 Any way to make this work among inventory and backpack too? (inventory n' chester/chest as well if possible?)Btw I made an icon for the mod, but don't want to release it yet, if you will be able to add that.. Link to comment Share on other sites More sharing options...
Blueberrys Posted March 1, 2015 Share Posted March 1, 2015 @IcyTheWhite Have you tested if it works with containers? I think it should work as it is. Link to comment Share on other sites More sharing options...
IcyTheWhite Posted March 2, 2015 Author Share Posted March 2, 2015 So between backpacks, it still works the old-fashioned way, but between chests and chester, it makes the equipped item drop in the 1st free space in inventory (probably same too as in vanilla). Would there be a way at the very least to make it work the same way for backpacks as for inventory items? Link to comment Share on other sites More sharing options...
Blueberrys Posted March 2, 2015 Share Posted March 2, 2015 @IcyTheWhite Possible, yes. Set item.prev_slot according to how it's referenced in the inventor and container components. Link to comment Share on other sites More sharing options...
IcyTheWhite Posted March 2, 2015 Author Share Posted March 2, 2015 Sadly @Blueberrys, I can't. I'm not a programmer and most of the code doesn't speak to me. =/I'm much more into graphics than programming, and that's why I won't most likely ever be able to make something more than basic code..If you want to help me, you would have to literally write down the whole code for me. I'm sorry.. Link to comment Share on other sites More sharing options...
IcyTheWhite Posted March 4, 2015 Author Share Posted March 4, 2015 Please, this will be the last thing I'm gonna bother you with @Blueberrys. ^^I really need this mod and I hate things to be half complete.. Link to comment Share on other sites More sharing options...
Blueberrys Posted March 4, 2015 Share Posted March 4, 2015 @IcyTheWhite I took a quick look at it and did not figure out what needs to be changed. I'm sorry, but I don't have the time to continue working on this. You're gonna have to try to figure it out yourself. It might take you longer to do that than it would take me, but I think it would be worthwhile. Look through the code for those components, see if you can understand what's going on. Do a few tests on what you find, then ask if you get stuck. Here are some resources to get you started:Container component (file is at "..\scripts\components\container")Inventory component (file is at "..\scripts\components\inventory")Simple DS-oriented lua tutorials Link to comment Share on other sites More sharing options...
IcyTheWhite Posted March 4, 2015 Author Share Posted March 4, 2015 Nah, I'm not gonna spent another 30+ hours learning lua.As I already mentioned, I'm not a programmer and I don't want to become one. It's just not my thing... 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.