Module:Monsters

Revision as of 18:12, 1 November 2025 by Choco (talk | contribs) (Created page with "local p = {} local data = {} -- Called by the data templates to register themselves function p.register(frame) local args = frame.args local name = args.name or "Unknown" data[name] = args return "" -- don't output anything directly end -- Get data for a monster function p.get(monster) return data[monster] end -- Generate a table row for the monster list function p.row(frame) local monster = frame.args[1] local m = data[monster] if not...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

local p = {} local data = {}

-- Called by the data templates to register themselves function p.register(frame)

   local args = frame.args
   local name = args.name or "Unknown"
   data[name] = args
   return ""  -- don't output anything directly

end

-- Get data for a monster function p.get(monster)

   return data[monster]

end

-- Generate a table row for the monster list function p.row(frame)

   local monster = frame.args[1]
   local m = data[monster]
   if not m then return "Missing data for "..monster end
   local out = {}
   table.insert(out, "|-")
   table.insert(out, string.format("| File:%s", m.image or ""))
   table.insert(out, string.format("|| %s", m.name or ""))
   table.insert(out, string.format("|| %s", m.element or "Unknown", m.element or "Unknown"))
   table.insert(out, string.format("|| %s || %s || %s || %s || %s || %s || %s",
       m.level or "?", m.exp or "?", m.hp or "?", m.atk or "?", m.def or "?",
       m.mp or "?", m.spd or "?"))
   table.insert(out, string.format("|| %s", m.drops or ""))
   return table.concat(out, "\n")

end

-- Generate a portable infobox for a monster function p.infobox(frame)

   local monster = frame.args[1]
   local m = data[monster]
   if not m then return "Missing data for "..monster end
   local out = {}
   table.insert(out, string.format("Template:Portable infobox\n")
   return table.concat(out, "\n")

end

return p