npo6ka / FNEI

Factorio NEI
https://mods.factorio.com/mods/npo6ka/FNEI
36 stars 21 forks source link

FNEI does not display the ingredients temperature range #61

Closed clampi closed 7 months ago

clampi commented 4 years ago

Recipe ingredients support more than a single value .temperature. See Ingredient properties. Some time back I remember FNEI supported the temperatures for ingredients, now it doesn't.

Here is some code that will bring back that functionality FNEI/scripts/recipe/gui.lua, ~line 479

  -- add temperature for fluid
  local function is_number(value) return "number" == type(value) end
  local function is_finite(value) return is_number(value) and value-(value-1) == 1 and value-(value+1) == -1 and -math.huge ~= value and math.huge ~= value end

  if element.type == "fluid" and Settings.get_val("show-temperature-of-fluids")  then
    if element.temperature then -- product
        loc_str = {"", loc_str, " (" .. element.temperature .. "°)"}
    elseif element.minimum_temperature and not is_finite(element.maximum_temperature) then -- ingredient
        loc_str = {"", loc_str, " ( ≥" .. element.minimum_temperature .. "°)"}
    elseif element.maximum_temperature and not is_finite(element.minimum_temperature) then -- ingredient
        loc_str = {"", loc_str, " ( ≤" .. element.maximum_temperature .. "°)"}
    elseif element.minimum_temperature and element.maximum_temperature then -- ingredient; must be after each of the single temperature value test
        if element.minimum_temperature == element.maximum_temperature then
            loc_str = {"", loc_str, " (" .. element.minimum_temperature .. "°)"}
        else
            loc_str = {"", loc_str, " ([" .. element.minimum_temperature .. ", " .. element.maximum_temperature .. "]°)"}
        end
    end
  end

Some points about the code.

Attached some snapshots of recipes with temperature restricted fluid ingredients, with the above code changes. FNEI_fluid_ingredients_temperature1

FNEI_fluid_ingredients_temperature2

npo6ka commented 4 years ago

Thank you for your feedback, I will try to fix this problem in the next updates!

npo6ka commented 7 months ago

a1bc6005837795ece12524bf1b030be80f95cf50