Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 0dd62c0

Browse files
Merge pull request #9 from theRustyKnife/1.6-dev
1.6.1
2 parents f882227 + 5344bc9 commit 0dd62c0

File tree

3 files changed

+51
-32
lines changed

3 files changed

+51
-32
lines changed
Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,71 @@
1-
##1.6.0##
1+
## 1.6.1 ##
2+
* Fixed stackable items with equipment grids could get deleted in some cases ([14638](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/14638))
3+
4+
## 1.6.0 ##
25
* Updated for Factorio 0.15
36

4-
##1.5.5##
7+
## 1.5.5 ##
58
* Fixed sorting of certain items would cause a crash when there were filters for them ([6067](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/6067))
69
* Fixed a possible crash when sorting cars or wagons with bigger inventories than any chest
710

8-
##1.5.4##
11+
## 1.5.4 ##
912
* Fixed filtered car sorting ([5284](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/5284))
1013

11-
##1.5.3##
14+
## 1.5.3 ##
1215
* Fixed temporary chests being selectable ([3947](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/3947))
1316

14-
##1.5.2##
17+
## 1.5.2 ##
1518
* No more temporary entity spawning and destroying on every player inventory sort
1619
* Fixed filtered cargo-wagons weren't sorted properly
1720

18-
##1.5.1##
21+
## 1.5.1 ##
1922
* Removed the left-over debugging message when auto-sorting
2023

21-
##1.5.0##
24+
## 1.5.0 ##
2225
* Internal changes
2326
* Improved auto-sort performance ([3558](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/3558))
2427

25-
##1.4.5##
28+
## 1.4.5 ##
2629
* Fixed GUI buttons would not appear when opened a logistic chest
2730
+ Added car and wagon sorting
2831
+ Added Russian translation thanks to [Apriori](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/3041)
2932

30-
##1.4.4##
33+
## 1.4.4 ##
3134
* Updated for Factorio 0.14
3235

33-
##1.4.3##
36+
## 1.4.3 ##
3437
* Fixed sorting big chests caused a crash ([2008](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/2008))
3538

36-
##1.4.2##
39+
## 1.4.2 ##
3740
* Fixed logistic chests were not sortable ([1519](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/1519))
3841

39-
##1.4.1##
42+
## 1.4.1 ##
4043
* Fixed a bug causing a crash when loading existing saves without the mod installed before ([1494](https://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort/discussion/1494))
4144

42-
##1.4.0##
45+
## 1.4.0 ##
4346
* Fixed broken migration script (hopefully), apologies to anyone who had problems with this - it should be safe now to migrate from any version to 1.4
4447
+ Added sorting GUI
4548

46-
##1.3.0##
49+
## 1.3.0 ##
4750
* Changed the default shortcuts to use shift instead of ctrl (it's a lot more comfortable this way)
4851
+ Added chest sorting
4952

50-
##1.2.0##
53+
## 1.2.0 ##
5154
+ Addded an options menu
5255
+ Added part inventory sorting
5356

54-
##1.1.2##
57+
## 1.1.2 ##
5558
* Use of new API features of 0.13.12 to get rid of the need to place temporary entities
5659

57-
##1.1.1##
60+
## 1.1.1 ##
5861
* Fixed auto-sort performance, now sorting is done only when actually needed
5962

60-
##1.1.0##
63+
## 1.1.0 ##
6164
* Fixed a bug making it possible to duplicate items with durability in certain cases
6265
+ Added the auto-sort feature. It has performance problems to be solved though.
6366

64-
##1.0.1##
67+
## 1.0.1 ##
6568
* Fixed a bug causing items to be lost when inserted in the tick after sorting was triggered
6669

67-
##1.0.0##
70+
## 1.0.0 ##
6871
+ Initial release

manual-inventory-sort/info.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "manual-inventory-sort",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"factorio_version": "0.15",
55
"title": "Manual Inventory Sorting",
66
"author": "TheRustyKnife",
7-
"description": "Makes some tweaks to the way inventory sorting works.\nYou can sort your inventory on demand or toggle auto-sort. Auto-sort can be configured to work for just a part of your inventory. \nIt's also possible to sort chests, cars and cargo wagons. \n0.15 supported!",
7+
"contact": "[email protected]",
8+
"description": "Makes some tweaks to the way inventory sorting works.\nYou can sort your inventory on demand or toggle auto-sort. Auto-sort can be configured to work for just a part of your inventory. \nIt's also possible to sort chests, cars and cargo wagons.",
89
"homepage": "http://mods.factorio.com/mods/theRustyKnife/manual-inventory-sort",
9-
"date": "24.04.2017",
10+
"date": "2017-06-05",
1011
"dependencies": ["base"]
11-
}
12+
}

manual-inventory-sort/script/sorting.lua

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,28 +148,35 @@ function sorting.sort_inventory(arg)
148148
for i = 1, #orders do -- go one order at a time, this also ensures that there's going to be only one item type in each iteration of this loop
149149
local t_stacks = util.get_staks_with_order(orders[i], stacks)
150150
local damaged_stacks = {} -- because stacks with damage go at the end
151+
local stacks_with_grid = {} -- put stacks with any equipment in their grid at the end (before damaged)
151152
local first = true -- first can't merge with previous stacks, since they're a different type
152153
i_slots.current_name = t_stacks[1].stack.name
153154
iterate_i_slots(i_slots, inventory)
154155

155156
for i_stack = 1, #t_stacks do
156157
local c_stack = t_stacks[i_stack]
157158

159+
local extra_properties = {}
160+
if c_stack.stack.grid and next(c_stack.stack.grid.equipment) ~= nil then extra_properties.grid = true; end
161+
if c_stack.stack.health and c_stack.stack.health ~= 1 and not extra_properties.grid then extra_properties.health = c_stack.stack.health; end -- don't insert if item has grid as that already handles moving to end
162+
158163
if not first and t_chest_inventory[i_slots.current].valid_for_read and t_chest_inventory[i_slots.current].name == c_stack.stack.name then -- there's a stack available for merge
159164
local free_space = c_stack.prototype.stack_size - t_chest_inventory[i_slots.current].count
160165

161-
local extra_properties = {}
162-
if c_stack.stack.type == "ammo" then extra_properties.ammo = c_stack.stack.ammo end
163-
if c_stack.stack.health and c_stack.stack.health ~= 1 then extra_properties.health = c_stack.stack.health end
164-
if c_stack.stack.durability then extra_properties.durability = c_stack.stack.durability end
166+
-- these are only needed when merging, so no point in getting them otherwise
167+
if c_stack.stack.type == "ammo" then extra_properties.ammo = c_stack.stack.ammo; end
168+
if c_stack.stack.durability then extra_properties.durability = c_stack.stack.durability; end
165169

166-
if extra_properties.ammo then -- ammo
170+
if extra_properties.ammo then -- ammo - maybe move this after the health and grid checks? Can ammo have health or grid?
167171
t_chest_inventory[i_slots.next].set_stack(c_stack.stack) -- put the stack into the next slot
168172
if util.compress_ammo(t_chest_inventory[i_slots.current], t_chest_inventory[i_slots.next]) then iterate_i_slots(i_slots, inventory) end -- merge stacks and only iterate i_slots.i if the next slot still as something in it
169-
173+
174+
elseif extra_properties.grid then -- item has an equipment grid attached to it - same as health
175+
table.insert(stacks_with_grid, c_stack)
176+
170177
elseif extra_properties.health then -- item is damaged - put at the end and do not stack!
171178
table.insert(damaged_stacks, c_stack)
172-
179+
173180
elseif extra_properties.durability then -- durability (same as ammo)
174181
t_chest_inventory[i_slots.next].set_stack(c_stack.stack)
175182
if util.compress_usable_stacks(t_chest_inventory[i_slots.current], t_chest_inventory[i_slots.next]) then iterate_i_slots(i_slots, inventory) end
@@ -186,7 +193,10 @@ function sorting.sort_inventory(arg)
186193
end
187194
end
188195
else -- there are no stacks to merge with
189-
if c_stack.stack.health and c_stack.stack.health ~= 1 then -- damaged - goes to the end
196+
if extra_properties.grid then -- has grid - goes to the end
197+
table.insert(stacks_with_grid, c_stack)
198+
199+
elseif extra_properties.health then -- damaged - goes to the end
190200
table.insert(damaged_stacks, c_stack)
191201

192202
else -- set it to the next stack
@@ -196,6 +206,11 @@ function sorting.sort_inventory(arg)
196206
end
197207
end
198208

209+
for i_grid = 1, #stacks_with_grid do -- insert stacks with grid (not sure what vanilla behavior is here, but I'm guessing it doesn't matter all that much)
210+
if not first then iterate_i_slots(i_slots, inventory) else first = false; end -- same as damaged
211+
t_chest_inventory[i_slots.current].set_stack(stacks_with_grid[i_grid].stack)
212+
end
213+
199214
for i_damaged = 1, #damaged_stacks do -- insert the dmaged stacks (for now these are inserted in the order they were originally - vanilla sorts them by ammount of health left)
200215
if not first then iterate_i_slots(i_slots, inventory) else first = false end -- prevent overwriting last non-damaged slot if there is one
201216
t_chest_inventory[i_slots.current].set_stack(damaged_stacks[i_damaged].stack)

0 commit comments

Comments
 (0)