Jump to content

Module:Charms

From Emps-World Wiki

local p = {}

function p.getCharm(frame)

   local hp = tonumber(frame.args.hp) or 0
   local combat = tonumber(frame.args.combat) or 0
   local charm = ""
   local itemId = 0
   -- Charm logic
   if hp <= 50 and combat <= 50 then
       charm = "Gold charm"
       itemId = 12158
   elseif hp <= 200 and combat <= 200 then
       charm = "Green charm"
       itemId = 12159
   elseif hp <= 500 and combat <= 500 then
       charm = "Crimson charm"
       itemId = 12160
   else
       charm = "Blue charm"
       itemId = 12163
   end
   local output = string.format(
       "
itemicon: invalid item id "%s"
%s",
       itemId,
       charm
   )
   return frame:preprocess(output)

end

return p