diff --git a/PHI-CL/data.lua b/PHI-CL/data.lua index 89ec855..3979c65 100644 --- a/PHI-CL/data.lua +++ b/PHI-CL/data.lua @@ -1,16 +1,3 @@ -if settings.startup['PHI-MB'].value then - if settings.startup['PHI-MB-ENERGY'].value and settings.startup['PHI-MB-ENERGY'].value > 1 then - require('data.b.mbe') - end - - if settings.startup['PHI-MB-MACHINE'].value and settings.startup['PHI-MB-MACHINE'].value > 1 then - require('data.b.mbm') - end - - if settings.startup['PHI-MB-EQUIPMENT'].value and settings.startup['PHI-MB-EQUIPMENT'].value > 1 then - require('data.b.mbq') - end -end if settings.startup['PHI-CT'].value then require('data.b.ct') @@ -40,3 +27,17 @@ if settings.startup['PHI-GM'].value then require('data.b.gm-vp') end end + +if settings.startup['PHI-MB'].value then + if settings.startup['PHI-MB-ENERGY'].value and settings.startup['PHI-MB-ENERGY'].value > 1 then + require('data.b.mbe') + end + + if settings.startup['PHI-MB-MACHINE'].value and settings.startup['PHI-MB-MACHINE'].value > 1 then + require('data.b.mbm') + end + + if settings.startup['PHI-MB-EQUIPMENT'].value and settings.startup['PHI-MB-EQUIPMENT'].value > 1 then + require('data.b.mbq') + end +end diff --git a/PHI-CL/data/b/main.lua b/PHI-CL/data/b/main.lua index 704c10c..8b7e3f1 100644 --- a/PHI-CL/data/b/main.lua +++ b/PHI-CL/data/b/main.lua @@ -338,20 +338,8 @@ function main.ER(source, tier) ingredient_name = (tier > source.min and (source.name .. '-' .. (tier - 1))) or source.ref_name end - if source.tech == 'compound-energy' then - if source.type == 'solar-panel' or source.type == 'accumulator' then - table.insert(ingredients, {type = 'item', name = ingredient_name, amount = tonumber(settings.startup['PHI-MB-ENERGY-SOLAR-RATIO'].value) or 4}) - - else - if tier > source.min then - table.insert(ingredients, {type = 'item', name = ingredient_name, amount = 1}) - table.insert(ingredients, {type = 'item', name = source.ref_name, amount = 1}) - - - else - table.insert(ingredients, {type = 'item', name = source.ref_name, amount = 2}) - end - end + if source.tech == 'compound-energy' and (source.type == 'solar-panel' or source.type == 'accumulator') then + table.insert(ingredients, {type = 'item', name = ingredient_name, amount = tonumber(settings.startup['PHI-MB-ENERGY-SOLAR-RATIO'].value) or 4}) else table.insert(ingredients, {type = 'item', name = ingredient_name, amount = 2}) @@ -375,19 +363,31 @@ end function main.ET(source, tier) if (source.tech == 'compound-energy') then table.insert(data.raw.technology['compound-energy-' .. (tier - 1)].effects, {type='unlock-recipe', recipe=source.name .. '-' .. tier}) + return + end - elseif data.raw.technology[source.tech] then - local recipe_name = (source.category == 'equipment' and (source.name .. '-mk' .. tier .. '-equipment')) or (source.name .. '-' .. tier) + if not data.raw.technology[source.tech] then + return + end + + local recipe_name = (source.category == 'equipment' and (source.name .. '-mk' .. tier .. '-equipment')) or (source.name .. '-' .. tier) + + if data.raw.technology[source.tech].effects then table.insert(data.raw.technology[source.tech].effects, {type='unlock-recipe', recipe=recipe_name}) - if source.type == 'ammo-turret' or source.type == 'fluid-turret' then - for i=1, #research_modifier[source.type], 1 do - for j=1, #data.raw.technology[research_modifier[source.type][i]].effects, 1 do - if (data.raw.technology[research_modifier[source.type][i]].effects[j].type == 'turret-attack') then - if (data.raw.technology[research_modifier[source.type][i]].effects[j].turret_id == source.ref_name) then - table.insert(data.raw.technology[research_modifier[source.type][i]].effects, {type='turret-attack', turret_id=source.name .. '-' .. tier, modifier=data.raw.technology[research_modifier[source.type][i]].effects[j].modifier}) - end - end + else + data.raw.technology[source.tech].effects = {{type='unlock-recipe', recipe=recipe_name}} + end + + if source.type ~= 'ammo-turret' and source.type ~= 'fluid-turret' then + return + end + + for i=1, #research_modifier[source.type], 1 do + if data.raw.technology[research_modifier[source.type][i]] and data.raw.technology[research_modifier[source.type][i]].effects then + for j=1, #data.raw.technology[research_modifier[source.type][i]].effects, 1 do + if (data.raw.technology[research_modifier[source.type][i]].effects[j].type == 'turret-attack') and (data.raw.technology[research_modifier[source.type][i]].effects[j].turret_id == source.ref_name) then + table.insert(data.raw.technology[research_modifier[source.type][i]].effects, {type='turret-attack', turret_id=source.name .. '-' .. tier, modifier=data.raw.technology[research_modifier[source.type][i]].effects[j].modifier}) end end end @@ -404,10 +404,12 @@ function main.EL(source) data.raw[source.type][source.name .. '-' .. 2].fast_replaceable_group = data.raw[source.type][source.ref_name].fast_replaceable_group end - if source.max > source.min then - for j=source.min + 1, source.max do - data.raw[source.type][source.name .. '-' .. j].fast_replaceable_group = data.raw[source.type][source.name .. '-' .. (j - 1)].fast_replaceable_group - end + if source.max <= source.min then + return + end + + for j=source.min + 1, source.max do + data.raw[source.type][source.name .. '-' .. j].fast_replaceable_group = data.raw[source.type][source.name .. '-' .. (j - 1)].fast_replaceable_group end end diff --git a/PHI-CL/data/b/mbe.lua b/PHI-CL/data/b/mbe.lua index 53a130e..bf9aa4d 100644 --- a/PHI-CL/data/b/mbe.lua +++ b/PHI-CL/data/b/mbe.lua @@ -39,7 +39,7 @@ for _, v in pairs(items) do v.mod = v.mod or 'base' v.min = v.min or 2 - if (v.mod and mods[v.mod]) and (v.max >= v.min) then + if (v.mod and mods[v.mod]) and (v.max >= v.min) and data.raw[v.type] and data.raw[v.type][v.name] and not data.raw[v.type][v.name].hidden then v.category = v.category or 'item' v.ref_name = v.ref_name or v.name v.tech = v.tech or 'compound-energy' diff --git a/PHI-CL/data/b/mbm.lua b/PHI-CL/data/b/mbm.lua index 4ab3e6d..7fb57ab 100644 --- a/PHI-CL/data/b/mbm.lua +++ b/PHI-CL/data/b/mbm.lua @@ -8,7 +8,7 @@ for _, v in pairs(items) do v.mod = v.mod or 'base' v.min = v.min or 2 - if (v.mod and mods[v.mod]) and (v.max >= v.min) then + if (v.mod and mods[v.mod]) and (v.max >= v.min) and data.raw[v.type] and data.raw[v.type][v.name] and not data.raw[v.type][v.name].hidden then v.category = v.category or 'item' v.ref_name = v.ref_name or v.name diff --git a/PHI-CL/data/b/mbq.lua b/PHI-CL/data/b/mbq.lua index 945e84e..84eafb3 100644 --- a/PHI-CL/data/b/mbq.lua +++ b/PHI-CL/data/b/mbq.lua @@ -114,7 +114,7 @@ for _, v in pairs(items) do v.mod = v.mod or 'base' v.min = v.min or 2 - if (v.mod and mods[v.mod]) and (v.max >= v.min) then + if (v.mod and mods[v.mod]) and (v.max >= v.min) and data.raw[v.type] and data.raw[v.type][v.name] and not data.raw[v.type][v.name].hidden then v.category = 'equipment' v.ref_name = v.ref_name or v.name .. '-equipment'