[MOD 0.12.33+] Sort Inventory button
[MOD 0.12.33+] Sort Inventory button
Hi,
here's a little mod to sort your inventory (group items, stack them)
only works for your main inventory
Because the always sorted option annoy me, but sometimes, I want to sort my items.
Type: Mod
Description: Add a 'S' button in top left corner to sort your inventory
License: modified MIT (my personnal version)
Version: 0.0.21
Release: 2016-05-29
Factorio Version: tested on 0.12.33
Category: Helper mod
dowload : ps :
Should be multiplayer compatible with version 0.0.21
here's a little mod to sort your inventory (group items, stack them)
only works for your main inventory
Because the always sorted option annoy me, but sometimes, I want to sort my items.
Type: Mod
Description: Add a 'S' button in top left corner to sort your inventory
License: modified MIT (my personnal version)
Version: 0.0.21
Release: 2016-05-29
Factorio Version: tested on 0.12.33
Category: Helper mod
dowload : ps :
Should be multiplayer compatible with version 0.0.21
- Attachments
-
- preview
- sort.jpg (145.58 KiB) Viewed 7558 times
Last edited by Kruparker on Sun May 29, 2016 3:42 pm, edited 1 time in total.
- sporefreak
- Fast Inserter
- Posts: 183
- Joined: Sun Apr 17, 2016 12:55 am
- Contact:
Re: [MOD 0.12.33+] Sort Inventory button
This is a great idea but I like sorted inventories. but I also like being able to move some things around as needed would it be possible to make it sort when you close your inventory?
Re: [MOD 0.12.33+] Sort Inventory button
I don't think so.sporefreak wrote: would it be possible to make it sort when you close your inventory?
I didn't find any event related to inventory (or key press), this is why the button is always visible.
You can click it whenever you want to sort your inventory.
Re: [MOD 0.12.33+] Sort Inventory button
When someone presses the button, you'll get a player_index. You can put this into game.players[player_index] instead of game.players[1].Kruparker wrote:I'm not sure how game.players[] work, so it could not work in multi, I still have to test it.
You also want to initialise the button with the on_player_created event. (This one also gives you a player_index).
Re: [MOD 0.12.33+] Sort Inventory button
MrDoomah wrote: When someone presses the button, you'll get a player_index. You can put this into game.players[player_index] instead of game.players[1].
okay, I didn't see that and was always thinking "How the hell do you know which player did something !"Api doc wrote: on_gui_click
Called when LuaGuiElement is clicked.
Contains
element :: LuaGuiElement: The clicked element.
player_index :: uint: The player who did the clicking.
answer => read the fucking manual, and learn to read >.<
now I've seen what I missed. I'll do it properly .MrDoomah wrote: You also want to initialise the button with the on_player_created event. (This one also gives you a player_index).
next update in some minutes
------------
edit : mod updated to support multiplayer (not tested yet) and updates
- sporefreak
- Fast Inserter
- Posts: 183
- Joined: Sun Apr 17, 2016 12:55 am
- Contact:
Re: [MOD 0.12.33+] Sort Inventory button
Would it work as a timer? Sorting at set intervals?Kruparker wrote:I don't think so.sporefreak wrote: would it be possible to make it sort when you close your inventory?
I didn't find any event related to inventory (or key press), this is why the button is always visible.
You can click it whenever you want to sort your inventory.
I don't like the idea of pressing a button to sort (I know I'm lazy but it gets tedious and I would never remember to do it)
If that's not possible then I might just make a script to sort when I open/close my inventory, Based on this mod. Thanks for the replies

Re: [MOD 0.12.33+] Sort Inventory button
I'm not sure it's a good idea.sporefreak wrote:Would it work as a timer? Sorting at set intervals?Kruparker wrote:I don't think so.sporefreak wrote: would it be possible to make it sort when you close your inventory?
I didn't find any event related to inventory (or key press), this is why the button is always visible.
You can click it whenever you want to sort your inventory.
I don't like the idea of pressing a button to sort (I know I'm lazy but it gets tedious and I would never remember to do it)
If that's not possible then I might just make a script to sort when I open/close my inventory, Based on this mod. Thanks for the replies
1) if I set a timer, the timer could trigger when you are playing with your inventory.
2) if I manage to detect inventory close/open and reorganize each time inventory is closed, what would happen if you make 10 little stacks of bullets to feed your turrets ?
After feeding the first turret, you'll have to recreate yours stacks, and so on..
Re: [MOD 0.12.33+] Sort Inventory button
hummm so opened_self was player inventory opened... not very clear >.<
Thanks !
I'll search if it's possible to add the button to the existing inventory gui.
At least, I could show the button when inventory is opened, hide it when inventory is closed.
and maybe add a configuration screen with a "sort on inventory exit " checkbox. But I'm still not sure if it's a good idea
PS : The method I use to sort inventory is not clean, really dirty. (create some fake chests, add items to chest, send them back inventory)
Because I find no way to work on COPIES(not references) of ItemStack.
I need real copies, I can't just create some vars, because I have to keep track of : bars, health, blueprintsetup/icons..., armor grid
LUA *~#{^# references everywhere makes it impossible because clear inventory means clear my vars >.>
If someone read this, and know how to do it, you'll have my eternal gratitude.
Thanks !
I'll search if it's possible to add the button to the existing inventory gui.
At least, I could show the button when inventory is opened, hide it when inventory is closed.
and maybe add a configuration screen with a "sort on inventory exit " checkbox. But I'm still not sure if it's a good idea
PS : The method I use to sort inventory is not clean, really dirty. (create some fake chests, add items to chest, send them back inventory)
Because I find no way to work on COPIES(not references) of ItemStack.
I need real copies, I can't just create some vars, because I have to keep track of : bars, health, blueprintsetup/icons..., armor grid
LUA *~#{^# references everywhere makes it impossible because clear inventory means clear my vars >.>
If someone read this, and know how to do it, you'll have my eternal gratitude.
Re: [MOD 0.12.33+] Sort Inventory button
Kruparker wrote:hummm so opened_self was player inventory opened... not very clear >.<
Thanks !
I'll search if it's possible to add the button to the existing inventory gui.
At least, I could show the button when inventory is opened, hide it when inventory is closed.
and maybe add a configuration screen with a "sort on inventory exit " checkbox. But I'm still not sure if it's a good idea
PS : The method I use to sort inventory is not clean, really dirty. (create some fake chests, add items to chest, send them back inventory)
Because I find no way to work on COPIES(not references) of ItemStack.
I need real copies, I can't just create some vars, because I have to keep track of : bars, health, blueprintsetup/icons..., armor grid
LUA *~#{^# references everywhere makes it impossible because clear inventory means clear my vars >.>
If someone read this, and know how to do it, you'll have my eternal gratitude.
Code: Select all
require "util"
copy = util.table.deepcopy(table)
Re: [MOD 0.12.33+] Sort Inventory button
thanks, you seem to be my savior, I tried "standard" deepcopy method found on the web but they all crashed my game.
could be what crashed my game.
I'll try this tomorrow, thanks
Code: Select all
-- don't copy factorio rich objects
I'll try this tomorrow, thanks
Re: [MOD 0.12.33+] Sort Inventory button
MrDoomah wrote:This creates a complete copy of a table, not just another reference. If you change a value in copy, it doesn't change it in table.Code: Select all
require "util" copy = util.table.deepcopy(table)
Yeah : It Works !
..
...
....
MY ASS ! >.<
It's now official I hate LUA.
Code: Select all
for i=1, inventorySize do
if inventory[i].valid_for_read then
memInventory = util.table.deepcopy(inventory[i])
memInventory.count = memInventory.count + 1
game.players[p_index].print("m:" .. memInventory.name .. ":" .. memInventory.count .. " i:" .. inventory[i].name .. ":" .. inventory[i].count )
end
end
instead of m:iron-plate:9 i:iron-plate:8
on a fresh new map. so my bag stack is incremented because of ]@^]}@~#^ reference
- sporefreak
- Fast Inserter
- Posts: 183
- Joined: Sun Apr 17, 2016 12:55 am
- Contact:
Re: [MOD 0.12.33+] Sort Inventory button
Wondering if i could ping you for an update? Just curious about where the mod is going, im thinking about doing another factorio playthrough and would love to have a sort on close inventory, I might try and make it happen myself if thats okay with you.
Re: [MOD 0.12.33+] Sort Inventory button
Sorry, I didn't see your post before (I was kind of busy).
If I have enough time, I could do something for the end of the week (and if 0.13 not breaks everything)
If you think you can do it yourself (better / before me), just do it. I won't complain (just tell me so we are not 2people working on the code for nothing).
You can do whatever you want with my code (sell it, keep it, modify it, redistributed with your own credits) , except licence under f*** viral GPL.
If you make modifications and want them to published with my original mod, send me back the modified sources.
If I have enough time, I could do something for the end of the week (and if 0.13 not breaks everything)
If you think you can do it yourself (better / before me), just do it. I won't complain (just tell me so we are not 2people working on the code for nothing).
You can do whatever you want with my code (sell it, keep it, modify it, redistributed with your own credits) , except licence under f*** viral GPL.
If you make modifications and want them to published with my original mod, send me back the modified sources.