-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbulk.lua
198 lines (184 loc) · 5.96 KB
/
bulk.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
local M = {}
local patterns = {
ore = {
-- generic
"crushed",
"dust",
"nugget",
"ore",
"pebble",
"powder",
"rock%-",
"rock$",
"%-rock%-",
"sand",
"slag",
-- angelsrefining
"^geode%-",
-- angelssmelting
"^processed%-",
-- angelspetrochem
"^solid%-",
-- Fluidless_Mining_and_Ore_Washing
"%-gangue$",
-- pyrawores
"^(low%-|high%-)grade%-",
"^reduced%-",
"^sintered%-",
"%-rejects$",
-- pyalienlife
"biomass",
"%-seeds",
"%-spore",
"%-leaves$",
-- pyalternative-energy
"^am%-",
"^cm%-",
"^pu%-",
"^u%-",
},
plates = {
"plate",
"ingot",
-- pymods
"%-alloy$",
}
}
-- bulk items that don't fit the above patterns
local items = {
-- base
"coal", "landfill", "plastic-bar", "stone", "sulfur",
-- bobores
"quartz",
-- bobplates
"carbon", "salt", "lithium-chloride", "lithium-perchlorate",
"sodium-hydroxide", "calcium-chloride", "lead-oxide", "alumina",
"tungsten-oxide", "silicon-nitride", "cobalt-oxide", "silicon-carbide",
"silver-nitrate", "silver-oxide",
-- bzcarbon
"flake-graphite", "rough-diamond", "fullerenes", "nanotubes", "graphene",
-- bzlead
"enriched-lead",
-- bzsilicon
"silica",
-- bztitanium
"enriched-titanium",
-- bztungsten
"enriched-tungsten",
-- bzzirconium
"zircon", "zirconia", "enriched-zircon", "zirconium-tungstate",
-- hardCrafting
"dirt",
-- Krastorio
"enriched-copper", "enriched-iron", "imersite", "k-coke", "k-lithium",
"k-lithium-chloride", "k-quartz", "k-raw-chunk", "k-silicon",
"k-tantalum", "k-titanium", "menarite", "raw-imersite", "raw-menarite",
"raw-minerals", "steel-billet",
-- Krastorio2
"raw-rare-metals", "lithium", "lithium-chloride", "silicon", "enriched-rare-metals",
-- omnimatter
"omnite",
-- pycoalprocessing
"active-carbon", "ash", "bonemeal", "borax", "boron-trioxide",
"calcium-carbide", "coal-briquette", "coarse", "coke", "dry-ralesia",
"fawogae", "fawogae-substrate", "gravel", "iron-oxide", "lime", "limestone",
"lithium-peroxide", "niobium-concentrate", "niobium-oxide", "organics",
"ppd", "ralesias", "raw-borax", "rich-clay", "soil",
"zinc-chloride",
-- pyrawores
"ammonium-chloride", "clean-nexelit", "coarse-coal", "concentrated-ti",
"concentrated-zinc", "crystalized-sodium-aluminate",
"gold-concentrate", "gold-precipitate", "gold-precipitate-2",
"high-chromite", "high-tin-concentrate", "high-tin-mix",
"iron-concentrate", "p2s5", "processed-chromite", "purified-gold",
"purified-quartz", "purified-zinc", "pyrite", "raw-coal", "redhot-coke",
"salt", "sl-concentrate", "sodium-aluminate", "sodium-bisulfate",
"sodium-carbonate", "sodium-hydroxide", "sodium-sulfate", "sponge-iron",
"starch", "tin-concentrate", "ti-residue", "unslimed-iron", "yellow-cake",
-- pyfusionenergy
"calcinates", "boron-carbide", "molybdenum-oxide",
-- pypetroleumhandling
"carbon-black", "guar", "soot",
-- pyhightech
"cadaveric-arum", "clay", "moondrop", "urea", "ree-concentrate", "reo",
"phenol", "raw-fiber", "lithium-niobate", "zinc-acetate",
"lard", "skin", "meat",
-- pyalienlife
"bonemeal", "bones", "brain", "cellulose", "chitin", "cobalt-extract",
"cobalt-fluoride", "cobalt-oxide", "dingrit-spike", "dried-grod", "grod",
"guts", "keratin", "lignin", "manure",
"moondrop-diesel", "moondrop-fueloil", "moondrop-gas", "moondrop-kerosene",
"moss", "rennea", "saps", "sea-sponge", "seaweed", "shell", "sporopollenin",
"sugar", "yaedols", "nisi", "sic", "green-sic",
-- pyalternativeenergy
"americium-oxide", "ammonium-mixture", "animal-eye", "arsenic",
"citric-acid", "crmoni", "crude-salt", "czts-slab",
"eg-si", "erbium", "ernico", "er-oxalate", "er-oxide", "eva",
"gaas", "lead-acetate", "lithium", "high-energy-waste-1",
"impure-er-oxide", "intermetallics", "inverse-opal",
"lithium-niobate-nano", "mositial-nx", "nbalti", "neodymium-oxide",
"nickel-nitrate", "nxzngd", "oxidized-pan-fiber", "plutonium-oxide",
"rhodamine-b", "self-assembly-monolayer", "sodium-citrate",
"sodium-cyanate", "ti-n", "uranium-oxide", "vitreloy", "yellow-dextrine",
-- space-exploration
"se-water-ice", "se-methane-ice", "se-vulcanite", "se-cryonite", "se-vitamelange", "se-beryllium-sulfate", "se-holmium-chloride", "se-naquium-refined",
-- Rich Rocks Requiem
"rrr-rich-rocks", "rrr-raw-minerals",
}
for i, item in ipairs(items) do
items[item] = true
items[i] = nil
end
-- runtime variables
local allowed_items_setting = settings.global["railloader-allowed-items"].value
local function item_matches_patterns(item_name, group)
for _, pat in ipairs(patterns[group]) do
if string.find(item_name, pat) then
return true
end
end
return false
end
local acceptable_item_cache = {}
local function is_acceptable_item(item_name)
if allowed_items_setting == "any" then
return true
end
local from_cache = acceptable_item_cache[item_name]
if from_cache ~= nil then
return from_cache
end
acceptable_item_cache[item_name] = items[item_name] or
item_matches_patterns(item_name, "ore") or
(allowed_items_setting == "ore, plates" and item_matches_patterns(item_name, "plates"))
return acceptable_item_cache[item_name]
end
function M.acceptable_items(inventories, limit)
local seen = {}
local out = {}
for _, inventory in pairs(inventories) do
for name in pairs(inventory.get_contents()) do
if is_acceptable_item(name) and not seen[name] then
seen[name] = true -- prevent the same item from taking two slots
out[#out+1] = name
if #out >= limit then
return out
end
end
end
end
return out
end
function M.add_bulk_item(item)
items[item] = true
acceptable_item_cache = {}
end
function M.add_bulk_item_pattern(pattern)
patterns.ore[#patterns+1] = pattern
acceptable_item_cache = {}
end
function M.on_setting_changed()
allowed_items_setting = settings.global["railloader-allowed-items"].value
acceptable_item_cache = {}
end
return M