Skip to content

Correctly show non-tiered ingredient amount in Create Tinker UI

Raf Geens requested to merge rgeens/t-engine4:fix-tinker-ui-ingredients into master

Don't merge this branch, it's an Embers of Rage fix and that doesn't seem to be included in the public git repositories, so I'm submitting the patch manually in this description.

Some ingredients quantities aren't reported correctly in the Create Tinker UI. You can for example be able to craft a healing salve while the troll intestine required ingredient shows an amount of 0. It's possible to craft the salve because the ingredient is in fact present, which you can see in the ingredients inventory. Screenshots here: http://forums.te4.org/viewtopic.php?f=42&t=50789

The cause is that the UI code for calculating the amount only took into account tiered ingredients like metals and herbs which have a number attached at the end. I expanded the logic so that non-tiered ingredients show the correct amount.

Patch is relative to the tome-orcs folder after unzipping orcs.teaac:

Index: overload/mod/dialogs/CreateTinker.lua
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- overload/mod/dialogs/CreateTinker.lua	(revision 5b95be02793b41461e49251b53b352908ff9465a)
+++ overload/mod/dialogs/CreateTinker.lua	(revision ef8306ea476ae126dfa67b3eb21ddf146df99e35)
@@ -163,8 +163,11 @@
 		str:add("Requires ingredients:", true)
 		for ing, qty in pairs(tdef.ingredients) do
 			local color = {"color", "LIGHT_RED"}
-			local amt = self.party:hasIngredient(ing..ml) and self.party.ingredients[ing..ml] or 0
-			if self.party:hasIngredient(ing..ml, qty) or self.party:hasIngredient(ing, qty) then color = {"color", "LIGHT_GREEN"} end
+			local amt = 0
+			if self.party:hasIngredient(ing..ml, qty) or self.party:hasIngredient(ing, qty) then
+				color = {"color", "LIGHT_GREEN" }
+				amt = self.party.ingredients[ing..ml] or self.party.ingredients[ing]
+			end
 			str:add("- ", color, (self.party:getIngredient(ing..ml) or self.party:getIngredient(ing)).name, " (", tostring(qty), ")", color, " (You have: ", tostring(amt), ")", {"color", "LAST"}, true)
 		end
 	end

Merge request reports

Loading