z_mirror/Krastorio2
git clone https://git.raiguard.me/z_mirror/Krastorio2
cd1a2400
trunk
1local data_util =require ( "data-util" ) 2 3--- @param technology data.TechnologyPrototype 4--- @param target_prerequisite_name data.TechnologyID 5--- @return boolean found 6local function find_prerequisite ( technology , target_prerequisite_name ) 7for _ , prerequisite_name in pairs ( technology . prerequisites or {} ) do 8if prerequisite_name == target_prerequisite_name then 9return true 10end 11local prerequisite =data . raw . technology [ prerequisite_name ] 12assert ( prerequisite , "Prerequisite " .. prerequisite_name .. "is not a valid technology." ) 13if find_prerequisite ( prerequisite , target_prerequisite_name ) then 14return true 15end 16end 17return false 18end 19 20for _ , technology in pairs ( data . raw . technology ) do 21local unit =technology . unit 22if not unit then 23goto continue 24end 25 26local ingredients =unit . ingredients 27if not ingredients then 28goto continue 29end 30 31local highest_pack =ingredients [ # ingredients ] 32if not highest_pack then 33goto continue 34end 35 36local highest_pack_name =highest_pack [ 1 ] 37if not highest_pack_name then 38goto continue 39end 40 41-- This assumes that there will either be an exact matching technology or that the science pack has a recipe with its same name. 42local science_pack_tech =data . raw . technology [ highest_pack_name ] 43or data_util . get_technology_for_recipe ( highest_pack_name ) 44if not science_pack_tech or science_pack_tech . name == technology . name then 45goto continue 46end 47 48if not find_prerequisite ( technology , science_pack_tech . name ) then 49log ( technology . name .. ": " .. science_pack_tech . name ) 50end 51 52:: continue :: 53end