Changes

decimal separator for ES numbers
Line 1: Line 1:  
--Assumes baseprice is always an integer
 
--Assumes baseprice is always an integer
--Adds the language-appropriate letter/character for 'gold'
+
--Adds the language-appropriate letters/characters for 'gold'
    
local p = {}
 
local p = {}
Line 10: Line 10:  
local quality = tonumber(frame.args.q)
 
local quality = tonumber(frame.args.q)
 
local profmult = tonumber(frame.args.pm)
 
local profmult = tonumber(frame.args.pm)
local ulang = string.upper(frame.args.ll)
+
local toFormatOrNotToFormat = string.lower(frame.args.fm)
    
if ((baseprice == nil) or (baseprice == 0)) then return 0 end
 
if ((baseprice == nil) or (baseprice == 0)) then return 0 end
Line 24: Line 24:  
end
 
end
   −
--Calculate artisan goods prices from base ingredient price
+
--Calculate some artisan goods prices from base ingredient price
--Some are hard-coded values, these should be replaced with values taken directly from data files (someday)
+
--These are needed for data-sort-values on pages like Flowers, Fruit, Vegetables
 
if (item == "wine") then
 
if (item == "wine") then
 
artisanprice = (baseprice * 3)
 
artisanprice = (baseprice * 3)
Line 32: Line 32:  
elseif ((item == "jelly") or (item == "pickles")) then
 
elseif ((item == "jelly") or (item == "pickles")) then
 
artisanprice = (50 + (baseprice * 2))
 
artisanprice = (50 + (baseprice * 2))
elseif (item == "roe") then
  −
artisanprice = (30 + math.floor(baseprice / 2))
  −
elseif (item == "aged roe") then
  −
artisanprice = (2 * (30 + math.floor(baseprice / 2)))
   
elseif (item == "honey") then
 
elseif (item == "honey") then
 
--This is a hack that works only because
 
--This is a hack that works only because
Line 44: Line 40:  
artisanprice = 100
 
artisanprice = 100
 
end
 
end
elseif (item == "caviar") then
+
elseif (string.find(item, "aged roe") ~= nil) then
artisanprice = 500
+
artisanprice = (2 * (30 + math.floor(baseprice / 2)))
elseif (item == "pale ale") then
+
elseif (string.find(item, "roe") ~= nil) then
artisanprice = 300
+
artisanprice = (30 + math.floor(baseprice / 2))
elseif ((item == "beer") or (item == "mead")) then
+
--[[elseif (item == "pale ale") then artisanprice = 300
artisanprice = 200
+
elseif ((item == "beer") or (item == "mead")) then artisanprice = 200
elseif (item == "cheese") then
+
elseif (item == "green tea") then artisanprice = 100
artisanprice = 230
+
elseif (item == "caviar") then artisanprice = 500
elseif (item == "goat cheese") then
+
elseif (item == "cheese") then artisanprice = 230
artisanprice = 400
+
elseif (item == "goat cheese") then artisanprice = 400
elseif (item == "green tea") then
+
elseif (item == "cloth") then artisanprice = 470
artisanprice = 100
+
elseif (item == "mayonnaise") then artisanprice = 190
elseif (item == "cloth") then
+
elseif (item == "duck mayonnaise") then artisanprice = 375
artisanprice = 470
+
elseif (item == "void mayonnaise") then artisanprice = 275
elseif (item == "mayonnaise") then
+
elseif (item == "dinosaur mayonnaise") then artisanprice = 800
artisanprice = 190
+
elseif (item == "truffle oil") then artisanprice = 1065
elseif (item == "duck mayonnaise") then
+
]]
artisanprice = 375
  −
elseif (item == "void mayonnaise") then
  −
artisanprice = 275
  −
elseif (item == "dinosaur mayonnaise") then
  −
artisanprice = 800
  −
elseif (item == "truffle oil") then
  −
artisanprice = 1065
   
else artisanprice = baseprice
 
else artisanprice = baseprice
 
end
 
end
    
local sum = math.floor(math.floor(profmult * 10 * math.floor(qualitymult * artisanprice)) / 10)
 
local sum = math.floor(math.floor(profmult * 10 * math.floor(qualitymult * artisanprice)) / 10)
 +
 +
if toFormatOrNotToFormat == "false" then return sum end
    
local formattedSum = mw.language.getContentLanguage():formatNum(sum)
 
local formattedSum = mw.language.getContentLanguage():formatNum(sum)
 +
local ulang = string.upper(mw.language.getContentLanguage():getCode())
    
if ulang == "DE" then return formattedSum .. " G"
 
if ulang == "DE" then return formattedSum .. " G"
elseif (ulang == "EN" or ulang == "HU" or ulang == "TR") then
+
elseif (ulang == "EN" or ulang == "JA" or ulang == "HU" or ulang == "TR") then
 
return formattedSum .. "g"
 
return formattedSum .. "g"
 +
elseif ulang == "ES" then
 +
if (sum < 1000) then return formattedSum .. "[[File:Gold.png|18px|link=]]"
 +
elseif (sum < 10000) then
 +
local length = #(tostring(sum))
 +
local temp = string.sub(tostring(sum), -3)
 +
return string.sub(tostring(sum), 1, (length-3)) .. "." .. temp .. "[[File:Gold.png|18px|link=]]"
 +
else
 +
local temp = {mw.ustring.gsub(tostring(formattedSum), "%s" , ".")}
 +
return temp[1] .. "[[File:Gold.png|18px|link=]]"
 +
end
 
elseif ulang == "FR" then return formattedSum .. "po"
 
elseif ulang == "FR" then return formattedSum .. "po"
 
elseif ulang == "IT" then return formattedSum .. "o"
 
elseif ulang == "IT" then return formattedSum .. "o"
106,358

edits