Difference between revisions of "Module:Infobox"

From Industrial-Craft-Wiki
Jump to navigation Jump to search
(Simple module to add a page to the right category)
 
(added tier)
 
(6 intermediate revisions by 2 users not shown)
Line 5: Line 5:
       args = f:getParent().args
       args = f:getParent().args
   end
   end
   return "[[Category:Blocks]]" .. f:expandTemplate{ title='Infobox', args = args }
   return f:expandTemplate{ title='Infobox', args = args }
end
end


Line 12: Line 12:
       args = f:getParent().args
       args = f:getParent().args
   end
   end
   return "[[Category:Items]]" .. f:expandTemplate{ title='Infobox', args = args }
    
  local title = args["title"] or ""
  local image = args["image"] or ""
  local invimage = args["invimage"] or ""
  local invimage2 = args["invimage2"] or ""
  local invimage3 = args["invimage3"] or ""
  local invimage4 = args["invimage4"] or ""
  local type = args["type"] or "Item"
  local tool = args["tool"] or "None"
  local tool2 = args["tool2"] or ""
  local armorrating = args["armorrating"] or ""
  local armortoughness = args["armortoughness"] or ""
  local damage = args["damage"] or ""
  local durability = args["durability"] or ""
  local mininglevel = args["mininglevel"] or ""
  local stackable = args["stackable"] or ""
  local flammable = args["flammable"] or ""
  local danger = args["danger"] or ""
  local protection = args["protection"] or ""
  local storageslots = args["storageslots"] or ""
  local lstorage = args["lstorage"] or ""
  local upgrades = args["upgrades"] or ""
  local tier = args["tier"] or ""
  local prevtier = args["prevtier"] or ""
  local nexttier = args["nexttier"] or ""
  local maxeu = args["maxeu"] or ""
  local eu_use = args["eu_use"] or ""
  local eu_use2 = args["eu_use2"] or ""
  local eu_op = args["eu_op"] or ""
  local storage = args["storage"] or ""
  local eu_produce = args["eu_produce"] or ""
  local maxout = args["maxout"] or ""
  local maxhu = args["maxhu"] or ""
  local hu_use = args["hu_use"] or ""
  local hu_use2 = args["hu_use2"] or ""
  local hu_produce = args["hu_produce"] or ""
  local maxku = args["maxku"] or ""
  local ku_use = args["ku_use"] or ""
  local ku_use2 = args["ku_use2"] or ""
  local ku_produce = args["ku_produce"] or ""
  local optime = args["optime"] or ""
  local uu = args["uu"] or args["uu_cost"] or ""
  local firstappearance = args["firstappearance"] or ""
  local lastappearance = args["lastappearance"] or ""
  local id = args["id"] or ""
  local fluidspeed = args["fluidspeed"] or ""
  local movespeed = args["movespeed"] or ""
 
  return f:expandTemplate{
      title='Infobox',
      args = {
        title = title,
        image = image,
        invimage = invimage,
        invimage2 = invimage2,
        invimage3 = invimage3,
        invimage4 = invimage4,
        type = type,
        tool = tool,
        tool2 = tool2,
        armorrating = armorrating,
        armortoughness = armortoughness,
        damage = damage,
        durability = durability,
        mininglevel = mininglevel,
        stackable = stackable,
        flammable = flammable,
        danger = danger,
        protection = protection,
        storageslots = storageslots,
        lstorage = lstorage,
        upgrades = upgrades,
        tier = tier,
        prevtier = prevtier,
        nexttier = nexttier,
        maxeu = maxeu,
        eu_use = eu_use,
        eu_use2 = eu_use2,
        eu_op = eu_op,
        storage = storage,
        eu_produce = eu_produce,
        maxout = maxout,
        maxhu = maxhu,
        hu_use = hu_use,
        hu_use2 = hu_use2,
        hu_produce = hu_produce,
        maxku = maxku,
        ku_use = ku_use,
        ku_use2 = ku_use2,
        ku_produce = ku_produce,
        optime = optime,
        uu = uu,
        firstappearance = firstappearance,
        lastappearance = lastappearance,
        id = id,
        fluidspeed = fluidspeed,
        movespeed = movespeed
      }
  }
end
end


return p
return p

Latest revision as of 21:52, 5 February 2021

Template-info.png Documentation

Work around for {{Block}} and {{Item}} needing to call {{Infobox}} and add categories (Category:Blocks and Category:Items receptively) to the pages calling them.

The above documentation is transcluded from Module:Infobox/doc. (edit | history)


local p = {}

function p.block( f )
   if f == mw.getCurrentFrame() then
       args = f:getParent().args
   end
   return f:expandTemplate{ title='Infobox', args = args }
end

function p.item( f )
   if f == mw.getCurrentFrame() then
       args = f:getParent().args
   end
   
   local title = args["title"] or ""
   local image = args["image"] or ""
   local invimage = args["invimage"] or ""
   local invimage2 = args["invimage2"] or ""
   local invimage3 = args["invimage3"] or ""
   local invimage4 = args["invimage4"] or ""
   local type = args["type"] or "Item"
   local tool = args["tool"] or "None"
   local tool2 = args["tool2"] or ""
   local armorrating = args["armorrating"] or ""
   local armortoughness = args["armortoughness"] or ""
   local damage = args["damage"] or ""
   local durability = args["durability"] or ""
   local mininglevel = args["mininglevel"] or ""
   local stackable = args["stackable"] or ""
   local flammable = args["flammable"] or ""
   local danger = args["danger"] or ""
   local protection = args["protection"] or ""
   local storageslots = args["storageslots"] or ""
   local lstorage = args["lstorage"] or ""
   local upgrades = args["upgrades"] or ""
   local tier = args["tier"] or ""
   local prevtier = args["prevtier"] or ""
   local nexttier = args["nexttier"] or ""
   local maxeu = args["maxeu"] or ""
   local eu_use = args["eu_use"] or ""
   local eu_use2 = args["eu_use2"] or ""
   local eu_op = args["eu_op"] or ""
   local storage = args["storage"] or ""
   local eu_produce = args["eu_produce"] or ""
   local maxout = args["maxout"] or ""
   local maxhu = args["maxhu"] or ""
   local hu_use = args["hu_use"] or ""
   local hu_use2 = args["hu_use2"] or ""
   local hu_produce = args["hu_produce"] or ""
   local maxku = args["maxku"] or ""
   local ku_use = args["ku_use"] or ""
   local ku_use2 = args["ku_use2"] or ""
   local ku_produce = args["ku_produce"] or ""
   local optime = args["optime"] or ""
   local uu = args["uu"] or args["uu_cost"] or ""
   local firstappearance = args["firstappearance"] or ""
   local lastappearance = args["lastappearance"] or ""
   local id = args["id"] or ""
   local fluidspeed = args["fluidspeed"] or ""
   local movespeed = args["movespeed"] or ""

   return f:expandTemplate{
      title='Infobox',
      args = {
         title = title,
         image = image,
         invimage = invimage,
         invimage2 = invimage2,
         invimage3 = invimage3,
         invimage4 = invimage4,
         type = type,
         tool = tool,
         tool2 = tool2,
         armorrating = armorrating,
         armortoughness = armortoughness,
         damage = damage,
         durability = durability,
         mininglevel = mininglevel,
         stackable = stackable,
         flammable = flammable,
         danger = danger,
         protection = protection,
         storageslots = storageslots,
         lstorage = lstorage,
         upgrades = upgrades,
         tier = tier,
         prevtier = prevtier,
         nexttier = nexttier,
         maxeu = maxeu,
         eu_use = eu_use,
         eu_use2 = eu_use2,
         eu_op = eu_op,
         storage = storage,
         eu_produce = eu_produce,
         maxout = maxout,
         maxhu = maxhu,
         hu_use = hu_use,
         hu_use2 = hu_use2,
         hu_produce = hu_produce,
         maxku = maxku,
         ku_use = ku_use,
         ku_use2 = ku_use2,
         ku_produce = ku_produce,
         optime = optime,
         uu = uu,
         firstappearance = firstappearance,
         lastappearance = lastappearance,
         id = id,
         fluidspeed = fluidspeed,
         movespeed = movespeed
      }
   }
end

return p