show-buildable/data-updates.lua

changeset 14
c26d4dd2af9b
child 19
adbc5c74f279
equal deleted inserted replaced
13:826df96c3720 14:c26d4dd2af9b
1 require("sb-util")
2
3 ---@param fluid_box data.FluidBox?
4 local function mangle_fluid_box(fluid_box)
5 if fluid_box
6 then
7 for _, pipe_connection in pairs (fluid_box.pipe_connections)
8 do
9 pipe_connection.position = {0, 0}
10 end
11 end
12 end
13
14 local function supported(entity_type)
15 if (entity_type == "rail-support" or entity_type == "rail-ramp")
16 and not feature_flags.rail_bridges
17 then
18 return false
19 else
20 return true
21 end
22 end
23
24 -- Make a bunch of dummy entities for collision testing purposes
25 local new_entities = {}
26 for _, entity_type in pairs (entity_categories)
27 do
28 for _, base_entity in pairs (supported(entity_type) and data.raw[entity_type] or {})
29 do
30 if has_flag(base_entity, "player-creation")
31 then
32 local new_entity = table.deepcopy (base_entity)
33 new_entity.name = "collision-tester-"..base_entity.name
34 new_entity.circuit_connector = nil
35 new_entity.next_upgrade = nil
36 new_entity.fast_replaceable_group = nil
37 mangle_fluid_box(new_entity.fluid_box)
38 for _, fluid_box in pairs (new_entity.fluid_boxes or {})
39 do
40 mangle_fluid_box(fluid_box)
41 end
42 mangle_fluid_box(new_entity.input_fluid_box)
43 mangle_fluid_box(new_entity.output_fluid_box)
44 mangle_fluid_box(new_entity.fuel_fluid_box)
45 mangle_fluid_box(new_entity.oxidizer_fluid_box)
46 if new_entity.type == "mining-drill"
47 or new_entity.type == "assembling-machine"
48 or new_entity.type == "fusion-generator"
49 or new_entity.type == "fusion-reactor"
50 or new_entity.type == "inserter"
51 or new_entity.type == "thruster"
52 or new_entity.type == "cargo-bay"
53 or new_entity.type == "cargo-landing-pad"
54 or new_entity.type == "transport-belt"
55 or new_entity.type == "splitter"
56 or new_entity.type == "container"
57 or new_entity.type == "loader"
58 or new_entity.type == "pump"
59 or new_entity.type == "rocket-silo"
60 or new_entity.type == "solar-panel"
61 then
62 -- I'd use simple entities here, but they need to be rotatable
63 new_entity.type = "assembling-machine"
64 new_entity.input_fluid_box = nil
65 new_entity.output_fluid_box = nil
66 new_entity.fluid_boxes = {}
67 new_entity.energy_usage = "1W"
68 new_entity.energy_source = {type="void"}
69 new_entity.crafting_speed = 1
70 new_entity.crafting_categories = {"crafting"}
71 new_entity.fixed_recipe = nil
72 new_entity.module_slots = 0
73 end
74 if (new_entity.type == "cargo-landing-pad" or new_entity.type == "cargo-bay")
75 and new_entity.graphics_set
76 then
77 new_entity.graphics_set.connections = nil
78 end
79 if (new_entity.type == "cargo-bay")
80 and new_entity.platform_graphics_set
81 then
82 new_entity.platform_graphics_set.connections = nil
83 end
84 table.insert (new_entities, new_entity)
85 end
86 end
87 end
88
89 data:extend (new_entities)

mercurial