-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess-items.lua
More file actions
121 lines (109 loc) · 3.73 KB
/
Copy pathprocess-items.lua
File metadata and controls
121 lines (109 loc) · 3.73 KB
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
local entities = require("entities")
local items = require("items")
local iterate_collection = require("iterate-collection")
local process_recipes = require("process-recipes")
local state = require("state")
return function()
local item_map = {}
local function process_item(name, proto)
local id = "item-" .. name
if proto.parameter then
-- Mark as removed so associated recipes will be filtered out
state.items_removed[id] = true
return
end
local sprite = "item/" .. name
local item = {
id = id,
icon = sprite,
stack = proto.stack_size,
rocketCapacity = proto.weight and proto.weight > 0 and
math.floor(prototypes.utility_constants.default_rocket_lift_weight / proto.weight) or
nil
}
if proto.fuel_value > 0 then
item.fuel = items.fuel(proto)
state.items_used[item.id] = true
end
if proto.type == "module" then
item.module = items.module(proto)
state.items_used[item.id] = true
end
table.insert(state.items_meta, {item = item, sprite = sprite, scale = 2, proto = proto})
state.item_map[item.id] = item
item_map[name] = item
end
local function process_entity(name, proto)
if proto.parameter then
return
end
if proto.type == "beacon" then
local item = item_map[name] or entities.item(proto)
item.beacon = entities.beacon(proto)
state.items_used[item.id] = true
elseif proto.type == "transport-belt" then
local item = item_map[name] or entities.item(proto)
item.belt = entities.belt(proto)
state.items_used[item.id] = true
elseif proto.type == "pump" then
local item = item_map[name] or entities.item(proto)
item.pipe = entities.pipe(proto)
state.items_used[item.id] = true
elseif
proto.type == "assembling-machine" or proto.type == "boiler" or proto.type == "burner-generator" or
proto.type == "furnace" or
proto.type == "fusion-generator" or
proto.type == "fusion-reactor" or
proto.type == "generator" or
proto.type == "lab" or
proto.type == "mining-drill" or
proto.type == "offshore-pump" or
proto.type == "reactor" or
proto.type == "rocket-silo"
then
local machine = entities.machine(proto, item)
if machine then
local item = item_map[name] or entities.item(proto)
item.machine = machine
state.items_used[item.id] = true
end
elseif proto.type == "cargo-wagon" then
local item = item_map[name] or entities.item(proto)
item.cargoWagon = entities.cargo_wagon(proto)
state.items_used[item.id] = true
elseif proto.type == "fluid-wagon" then
local item = item_map[name] or entities.item(proto)
item.fluidWagon = entities.fluid_wagon(proto)
state.items_used[item.id] = true
elseif proto.type == "inserter" then
local item = item_map[name] or entities.item(proto)
item.inserter = entities.inserter(proto)
state.items_used[item.id] = true
end
end
local function process_fluid(name, proto)
if proto.parameter then
return
end
local sprite = "fluid/" .. name
local item = {
id = "fluid-" .. name,
icon = sprite
}
table.insert(state.items_meta, {item = item, sprite = sprite, scale = 2, proto = proto})
state.item_map[item.id] = item
end
iterate_collection(
prototypes.item,
process_item,
function()
iterate_collection(
prototypes.entity,
process_entity,
function()
iterate_collection(prototypes.fluid, process_fluid, process_recipes)
end
)
end
)
end