Difference between revisions of "Module:IconBar"

From Minetest Wiki
Jump to navigation Jump to search
m
m
Line 1: Line 1:
 
local p = {}
 
local p = {}
  
function p.hearts(frame)
+
function p.hearts(frame, num)
     local num = tonumber(frame.args[1]) or 1
+
     num = num or 1
 
     if num == 0 then
 
     if num == 0 then
 
         return "[[File:Empty heart.png|16px]]"
 
         return "[[File:Empty heart.png|16px]]"

Revision as of 15:11, 8 April 2017

local p = {}

function p.hearts(frame, num)

   num = num or 1
   if num == 0 then
       return "Empty heart.png"
   end
   local numFloor = math.floor(num)
   local s = ""
   for i = 1, numFloor do
       s = s .. "Heart.png"
   end
   if numFloor ~= num then
       s = s .. "Half heart.png"
   end
   return s

end

return p