From d049f79d08c7c4b5b39ef806d0dda098127d825d Mon Sep 17 00:00:00 2001 From: scamtank Date: Fri, 12 Jun 2015 00:10:50 +0300 Subject: [PATCH 1/3] Make second function do what the first won't Dummy out the DRINK_MAT lookup in the first one to stop the overlap, make the second one look up all the stuff that the first one expects to find with material reaction product tokens. --- scripts/view-item-info.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/view-item-info.lua b/scripts/view-item-info.lua index 9ea539ca2..db5e1b441 100644 --- a/scripts/view-item-info.lua +++ b/scripts/view-item-info.lua @@ -249,7 +249,7 @@ end function get_plant_reaction_products (mat) local list = {} - add_react_prod (list, mat, "DRINK_MAT", "Used to brew ") +-- add_react_prod (list, mat, "DRINK_MAT", "Used to brew ") -- redundant with the jury-rig in the next function add_react_prod (list, mat, "GROWTH_JUICE_PROD", "Pressed into ") add_react_prod (list, mat, "PRESS_LIQUID_MAT", "Pressed into ") add_react_prod (list, mat, "LIQUID_EXTRACTABLE", "Extractable product: ") @@ -290,15 +290,26 @@ function GetFoodPropertiesStringList (item) if item._type == df.item_plantst and GetMatPlant (item) then local plant = GetMatPlant (item) for k,v in pairs (plant.material_defs) do - if v ~= -1 and string.find (k,"type_") and not string.find (k,"type_basic") - or string.find (k,"type_seed") or string.find (k,"type_tree") then + if v ~= -1 and string.find (k,"type_") and not (string.find (k,"type_basic") + or string.find (k,"type_seed") or string.find (k,"type_tree")) then local targetmat = dfhack.matinfo.decode (v, plant.material_defs["idx_"..string.match (k,"type_(.+)")]) local state = "Liquid" - if string.find (k,"type_mill") then state = "Powder" - elseif string.find (k,"type_thread") then state = "Solid" end + local describe = "Made into " + if string.find (k,"type_mill") + then state = "Powder" describe = "Ground into " + elseif string.find (k,"type_thread") + then state = "Solid" describe = "Woven into " + elseif string.find (k,"type_drink") + then describe = "Brewed into " + elseif string.find (k,"type_extract_barrel") + then describe = "Cask-aged into " + elseif string.find (k,"type_extract_vial") + then describe = "Refined into vials of " + elseif string.find (k,"type_extract_still_vial") + then describe = "Distilled into vials of " end local st_name = targetmat.material.state_name[state] - append(list,"Used to make "..targetmat.material.prefix..''..st_name) + append(list,describe..targetmat.material.prefix..''..st_name) end end end From 01a3ed627f9b89b0fbd0a5cf0903f92fdc9c4969 Mon Sep 17 00:00:00 2001 From: scamtank Date: Fri, 12 Jun 2015 00:53:49 +0300 Subject: [PATCH 2/3] Just delete the thing If there's need for the DRINK_MAT thing again, it's no big deal to write it back. --- scripts/view-item-info.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/view-item-info.lua b/scripts/view-item-info.lua index db5e1b441..1f83e0807 100644 --- a/scripts/view-item-info.lua +++ b/scripts/view-item-info.lua @@ -249,7 +249,6 @@ end function get_plant_reaction_products (mat) local list = {} --- add_react_prod (list, mat, "DRINK_MAT", "Used to brew ") -- redundant with the jury-rig in the next function add_react_prod (list, mat, "GROWTH_JUICE_PROD", "Pressed into ") add_react_prod (list, mat, "PRESS_LIQUID_MAT", "Pressed into ") add_react_prod (list, mat, "LIQUID_EXTRACTABLE", "Extractable product: ") From 64c92802c29a7f6642a2644ddbf43839fd53480f Mon Sep 17 00:00:00 2001 From: scamtank Date: Fri, 12 Jun 2015 03:22:05 +0300 Subject: [PATCH 3/3] String.find(k) into k:find Looks neater already. --- scripts/view-item-info.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/view-item-info.lua b/scripts/view-item-info.lua index 1f83e0807..acadb134c 100644 --- a/scripts/view-item-info.lua +++ b/scripts/view-item-info.lua @@ -289,23 +289,23 @@ function GetFoodPropertiesStringList (item) if item._type == df.item_plantst and GetMatPlant (item) then local plant = GetMatPlant (item) for k,v in pairs (plant.material_defs) do - if v ~= -1 and string.find (k,"type_") and not (string.find (k,"type_basic") - or string.find (k,"type_seed") or string.find (k,"type_tree")) then + if v ~= -1 and k:find("type_") and not (k:find("type_basic") + or k:find("type_seed") or k:find("type_tree")) then local targetmat = dfhack.matinfo.decode (v, - plant.material_defs["idx_"..string.match (k,"type_(.+)")]) + plant.material_defs["idx_"..k:match("type_(.+)")]) local state = "Liquid" local describe = "Made into " - if string.find (k,"type_mill") + if k:find("type_mill") then state = "Powder" describe = "Ground into " - elseif string.find (k,"type_thread") + elseif k:find("type_thread") then state = "Solid" describe = "Woven into " - elseif string.find (k,"type_drink") + elseif k:find("type_drink") then describe = "Brewed into " - elseif string.find (k,"type_extract_barrel") + elseif k:find("type_extract_barrel") then describe = "Cask-aged into " - elseif string.find (k,"type_extract_vial") + elseif k:find("type_extract_vial") then describe = "Refined into vials of " - elseif string.find (k,"type_extract_still_vial") + elseif k:find("type_extract_still_vial") then describe = "Distilled into vials of " end local st_name = targetmat.material.state_name[state] append(list,describe..targetmat.material.prefix..''..st_name)