Jump to content

[Request] Tiny Tweak - Equipment Sorting

Recommended Posts

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



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

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

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

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

@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:

Link to comment
Share on other sites


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.

  • Create New...