comparison ReagentMaker.lua @ 116:7ce304c296b0

Display then number of makable items instead of the number of times the recipe is craftable
author contrebasse
date Wed, 15 Jun 2011 01:14:00 +0200
parents 5a3fb8fea026
children e6bb47c6d8d6
comparison
equal deleted inserted replaced
115:5a3fb8fea026 116:7ce304c296b0
195 -- Continue only if the reagent is known 195 -- Continue only if the reagent is known
196 if not reagentID or not A.data[reagentID] then 196 if not reagentID or not A.data[reagentID] then
197 label:Hide() 197 label:Hide()
198 else 198 else
199 -- Count and show 199 -- Count and show
200 local numMakable = A.numMakable(reagentID) 200 local numMakableMin, numMakableMax, numMakableIsApprox = A.numMakable(reagentID)
201 if not numMakable then 201 if not numMakableMin then
202 label:SetText("?") 202 label:SetText("?")
203 label:SetTextColor(0, 0.5, 1, 1) -- blue 203 label:SetTextColor(0, 0.5, 1, 1) -- blue
204 else 204 else
205 label:SetText(numMakable) 205 local txt = numMakableIsApprox and "~" or ""
206 if numMakable==0 then 206 if numMakableMin == numMakableMax then
207 label:SetFormattedText("%s%.2g",txt,numMakableMin)
208 else
209 label:SetFormattedText("%s%.2g-%.2g",txt,numMakableMin,numMakableMax)
210 end
211 if numMakableMax==0 then
207 label:SetTextColor(1, 0, 0, 1) -- red 212 label:SetTextColor(1, 0, 0, 1) -- red
208 else 213 else
209 label:SetTextColor(0, 1, 0, 1) -- green 214 label:SetTextColor(0, 1, 0, 1) -- green
210 end 215 end
211 end -- if 216 end -- if