-
Notifications
You must be signed in to change notification settings - Fork 30
/
data-final-fixes.lua
76 lines (71 loc) · 3.13 KB
/
data-final-fixes.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
if not mods.pyalternativeenergy then
for _, recipe in pairs(data.raw.recipe) do
if not recipe.localised_name and recipe.category == "combustion" and not recipe.name:find("%-biomass$") then
local temp
for _, result in pairs(recipe.results) do
if result.name == "combustion-mixture1" then
temp = result.temperature
end
end
recipe.localised_name = {"recipe-name." .. recipe.name, tostring(temp)}
end
end
end
require "prototypes/map-gen-presets"
-- Updating requester paste setting
local rpm_entity = tonumber(settings.startup["rpm_entity"].value)
local rpm_items = tonumber(settings.startup["rpm_items"].value)
local overload = tonumber(settings.startup["overload"].value)
if rpm_entity ~= 30 or rpm_items ~= 30 or overload ~= 0 then
--log("Updating recipe requester paste values")
--These types (data.raw[entity_type]) are placeable entities
local entity_types = defines.prototypes.entity
-- We store the result of each lookup so we don't have to do it again
-- When iterating *the entire recipe table X every individual result* this is worthwhile!
local valid_entities = {}
-- This is only hit when we request an index that doesn't exist (name we haven't checked)
-- We then check if it's an entity and make an entry for that answer, followed by returning that result
setmetatable(valid_entities, {
__index = function(self, index)
local item = data.raw.item[index]
-- Place result?
if item and item.place_result then
rawset(self, index, true)
return true
end
-- Valid entity?
for type_name, _ in pairs(entity_types) do
if data.raw[type_name] and data.raw[type_name][index] then
rawset(self, index, true)
return true
end
end
-- Otherwise, nope!
rawset(self, index, false)
return false
end
})
for _, recipe in pairs(data.raw.recipe) do
if not recipe.results then
goto continue
end
for _, result in pairs(recipe.results) do -- This looks long, however we skip a lot of the logic with caching
local result_name = result[1] or result.name
if result_name and valid_entities[result_name] then
--log("Set multiplier for " .. recipe.name .. " (" .. result_name .. ")")
recipe.requester_paste_multiplier = tonumber(rpm_entity)
recipe.overload_multiplier = tonumber(overload)
goto continue
end
end
recipe.requester_paste_multiplier = tonumber(rpm_items)
recipe.overload_multiplier = tonumber(overload)
::continue::
end
end
data.raw["utility-constants"].default.minimum_recipe_overload_multiplier = 1
for _, recipe in pairs(data.raw.recipe) do
if recipe.category == "tar" and not recipe.crafting_machine_tint then
error("Recipe " .. recipe.name .. " is missing crafting_machine_tint. Please fill out this field.")
end
end