Module:Infobox Item: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
ret:defineParams{ | ret:defineParams{ | ||
--- General | --- General -- | ||
{ name = 'name', func = 'name' }, | { name = 'name', func = 'name' }, | ||
{ name = 'image', func = 'image' }, | { name = 'image', func = 'image' }, | ||
| Line 25: | Line 25: | ||
{ name = 'sell', func = 'has_content' }, -- Todo: Unsellable | { name = 'sell', func = 'has_content' }, -- Todo: Unsellable | ||
-- Properties | -- Properties -- | ||
{ name = 'tradable', func = 'yes_no' }, | { name = 'tradable', func = 'yes_no' }, | ||
{ name = 'quest', func = 'has_content' }, | { name = 'quest', func = 'has_content' }, | ||
-- Market values | -- Market values -- | ||
{ name = 'market_sp_limit', func = 'has_content' }, -- sell price | { name = 'market_sp_limit', func = 'has_content' }, -- sell price | ||
{ name = 'market_bp_limit', func = 'has_content' }, -- buy price | { name = 'market_bp_limit', func = 'has_content' }, -- buy price | ||
-- | -- Item type Properties -- | ||
{ name = 'type', func = 'has_content' }, -- Item type | |||
-- Potion Params -- | |||
{ name = 'potion_type', func = 'has_content' }, | |||
{ name = 'potion_effect', func = 'has_content' }, | |||
-- Book Params -- | |||
{ name = 'book_author', func = 'has_content' }, | |||
-- Armor Params -- | |||
{ name = 'damage_blocked', func = 'has_content' }, | |||
-- Fish Params -- | |||
-- Gemstone Params -- | |||
{ name = 'gem_effect', func = 'has_content' }, | |||
-- Log Params -- | |||
{ name = 'chop_level', func = 'has_content' }, | |||
-- Necklace Params -- | |||
-- Ore Params -- | |||
{ name = 'mine_level', func = 'has_content' }, | |||
-- Ring Params -- | |||
{ name = 'ring_effect', func = 'has_content' }, | |||
-- Rune Params -- | |||
{ name = 'rune_tp', func = 'has_content' }, | |||
-- Tool Params -- | |||
{ name = 'tool_type', func = 'has_content' }, | |||
{ name = 'tool_level', func = 'has_content' }, | |||
-- Trap Params -- | |||
-- Trophy Params -- | |||
-- Weapon Params -- | |||
} | } | ||
| Line 88: | Line 138: | ||
{ tag = 'argd', content = 'id', colspan = '13' }, | { tag = 'argd', content = 'id', colspan = '13' }, | ||
} | } | ||
:pad(20) | |||
:addRow{ | |||
{ tag = 'th', content = 'Type', colspan = '7' }, | |||
{ tag = 'argd', content = 'type', colspan = '13' }, | |||
} | |||
:pad(20) | :pad(20) | ||
:addRow{ | :addRow{ | ||
| Line 165: | Line 219: | ||
end | end | ||
--[[ | |||
Add rows for potion stuff | |||
]] | |||
local hasPotionType = ret:paramDefined('potion_type') | |||
local hasPotionEffect = ret:paramDefined('potion_effect') | |||
if hasPotionType or hasPotionEffect then | |||
ret:pad(20) | |||
:addRow{ | |||
{ tag = 'th', content = 'Potion Info', class = 'infobox-subheader', colspan = '20' }, | |||
} | |||
if hasPotionType then | |||
ret:pad(20) | |||
:addRow{ | |||
{ tag = 'th', content = 'Type', colspan = '7' }, | |||
{ tag = 'argd', content = 'potion_type', colspan = '13' }, | |||
} | |||
end | |||
if hasPotionEffect then | |||
ret:pad(20) | |||
:addRow{ | |||
{ tag = 'th', content = 'Effect', colspan = '7' }, | |||
{ tag = 'argd', content = 'potion_effect', colspan = '13' }, | |||
} | |||
end | |||
end | |||
--[[ | |||
Add rows for armor stuff | |||
]] | |||
if ret:paramDefined('damage_blocked') then | |||
ret:pad(20) | |||
:addRow{ | |||
{ tag = 'th', content = 'Armor', class = 'infobox-subheader', colspan = '20' }, | |||
} | |||
:pad(20) | |||
:addRow{ | |||
{ tag = 'th', content = 'Damage blocked', colspan = '7' }, | |||
{ tag = 'argd', content = 'damage_blocked', colspan = '13' }, | |||
} | |||
end | |||
--[[ | |||
Add rows for book stuff | |||
]] | |||
if ret:paramDefined('book_author') then | |||
ret:pad(20) | |||
:addRow{ | |||
{ tag = 'th', content = 'Book', class = 'infobox-subheader', colspan = '20' }, | |||
} | |||
:pad(20) | |||
:addRow{ | |||
{ tag = 'th', content = 'Author', colspan = '7' }, | |||
{ tag = 'argd', content = 'book_author', colspan = '13' }, | |||
} | |||
end | |||
ret:finish() | ret:finish() | ||
Revision as of 09:24, 1 April 2022
Documentation for this module may be created at Module:Infobox Item/doc
--------------------------
-- Module for [[Template:Infobox Item]]
------------------------
local p = {}
local infobox = require('Module:Experimental/Infobox')
local onmain = require('Module:Mainonly').on_main
local commas = require('Module:Addcommas')._add
VariablesLua = mw.ext.VariablesLua
function p.main(frame)
local args = frame:getParent().args
local ret = infobox.new(args)
ret:defineParams{
--- General --
{ name = 'name', func = 'name' },
{ name = 'image', func = 'image' },
{ name = 'release', func = 'release' },
{ name = 'id', func = 'number' },
{ name = 'description', func = 'has_content' },
{ name = 'members', func = 'yes_no' },
{ name = 'level', func = 'number' },
{ name = 'cost', func = 'has_content' }, -- Todo: Unbuyable
{ name = 'sell', func = 'has_content' }, -- Todo: Unsellable
-- Properties --
{ name = 'tradable', func = 'yes_no' },
{ name = 'quest', func = 'has_content' },
-- Market values --
{ name = 'market_sp_limit', func = 'has_content' }, -- sell price
{ name = 'market_bp_limit', func = 'has_content' }, -- buy price
-- Item type Properties --
{ name = 'type', func = 'has_content' }, -- Item type
-- Potion Params --
{ name = 'potion_type', func = 'has_content' },
{ name = 'potion_effect', func = 'has_content' },
-- Book Params --
{ name = 'book_author', func = 'has_content' },
-- Armor Params --
{ name = 'damage_blocked', func = 'has_content' },
-- Fish Params --
-- Gemstone Params --
{ name = 'gem_effect', func = 'has_content' },
-- Log Params --
{ name = 'chop_level', func = 'has_content' },
-- Necklace Params --
-- Ore Params --
{ name = 'mine_level', func = 'has_content' },
-- Ring Params --
{ name = 'ring_effect', func = 'has_content' },
-- Rune Params --
{ name = 'rune_tp', func = 'has_content' },
-- Tool Params --
{ name = 'tool_type', func = 'has_content' },
{ name = 'tool_level', func = 'has_content' },
-- Trap Params --
-- Trophy Params --
-- Weapon Params --
}
ret:setMaxButtons(7)
ret:create()
ret:cleanParams()
ret:customButtonPlacement(true)
ret:setDefaultVersionSMW(true)
ret:defineLinks({ hide = true })
-- ret:useSMWOne({
-- members = 'All Is members only',
-- id_smw = 'All Item ID',
-- image_smw = 'All Image',
-- })
-- ret:useSMWSubobject({
-- version = 'Version anchor',
-- release = 'Release date',
-- id_smw = 'Item ID',
-- description = 'Description',
-- members = 'Is members only',
-- buyvalue = 'Buyable for',
-- sellvalue = 'Sellable for',
-- image_smw = 'Image',
-- market_buy_limit = 'Buy limits',
-- market_sell_limit = 'Sell limits',
-- usesinfobox = 'Uses infobox',
-- })
ret:addButtonsCaption()
ret:defineName('Infobox Item')
ret:addClass('infobox-item')
ret:addRow{
{ tag = 'argh', content = 'name', class = 'infobox-header', colspan = '20' }
}
:pad(20)
:addRow{
{ tag = 'argd', content = 'image', class = 'infobox-image infobox-full-width-content', colspan = '20' }
}
:addRow{
{ tag = 'argd', content = 'description', class = 'infobox-desription infobox-full-width-content', colspan = '20' }
}
:pad(20)
:addRow{
{ tag = 'th', content = 'ID', colspan = '7' },
{ tag = 'argd', content = 'id', colspan = '13' },
}
:pad(20)
:addRow{
{ tag = 'th', content = 'Type', colspan = '7' },
{ tag = 'argd', content = 'type', colspan = '13' },
}
:pad(20)
:addRow{
{ tag = 'th', content = 'Released', colspan = '7' },
{ tag = 'argd', content = 'release', colspan = '13' },
}
:pad(20)
:addRow{
{ tag = 'th', content = '[[Members]]', colspan = '7' },
{ tag = 'argd', content = 'members', colspan = '13' },
}
:pad(20)
:addRow{
{ tag = 'th', content = 'Level', colspan = '7' },
{ tag = 'argd', content = 'level', colspan = '13' },
}
:pad(20)
:addRow{
{ tag = 'th', content = 'Buy Price', colspan = '7' },
{ tag = 'argd', content = 'cost', colspan = '13' },
}
:pad(20)
:addRow{
{ tag = 'th', content = 'Sell Price', colspan = '7' },
{ tag = 'argd', content = 'sell', colspan = '13' },
}
--[[
Add rows for properties
]]
:pad(20)
:addRow{
{ tag = 'th', content = 'Properties', class = 'infobox-subheader', colspan = '20' },
}
:pad(20)
:addRow{
{ tag = 'th', content = 'Tradable', colspan = '7' },
{ tag = 'argd', content = 'tradable', colspan = '13' },
}
:pad(20)
:addRow{
{ tag = 'th', content = '[[Quests|Quest]]', colspan = '7' },
{ tag = 'argd', content = 'quest', colspan = '13' },
}
--[[
Add rows for Market stuff
]]
local hasMarketSPLimit = ret:paramDefined('market_sp_limit')
local hasMarketBPLimit = ret:paramDefined('market_bp_limit')
if hasMarketSPLimit or hasMarketBPLimit then
ret:pad(20)
:addRow{
{ tag = 'th', content = 'Market Limits', class = 'infobox-subheader', colspan = '20' },
}
if hasMarketSPLimit then
ret:pad(20)
:addRow{
{ tag = 'th', content = 'Sell Price', colspan = '7' },
{ tag = 'argd', content = 'market_sp_limit', colspan = '13' },
}
end
if hasMarketBPLimit then
ret:pad(20)
:addRow{
{ tag = 'th', content = 'Buy Price', colspan = '7' },
{ tag = 'argd', content = 'market_bp_limit', colspan = '13' },
}
end
end
--[[
Add rows for potion stuff
]]
local hasPotionType = ret:paramDefined('potion_type')
local hasPotionEffect = ret:paramDefined('potion_effect')
if hasPotionType or hasPotionEffect then
ret:pad(20)
:addRow{
{ tag = 'th', content = 'Potion Info', class = 'infobox-subheader', colspan = '20' },
}
if hasPotionType then
ret:pad(20)
:addRow{
{ tag = 'th', content = 'Type', colspan = '7' },
{ tag = 'argd', content = 'potion_type', colspan = '13' },
}
end
if hasPotionEffect then
ret:pad(20)
:addRow{
{ tag = 'th', content = 'Effect', colspan = '7' },
{ tag = 'argd', content = 'potion_effect', colspan = '13' },
}
end
end
--[[
Add rows for armor stuff
]]
if ret:paramDefined('damage_blocked') then
ret:pad(20)
:addRow{
{ tag = 'th', content = 'Armor', class = 'infobox-subheader', colspan = '20' },
}
:pad(20)
:addRow{
{ tag = 'th', content = 'Damage blocked', colspan = '7' },
{ tag = 'argd', content = 'damage_blocked', colspan = '13' },
}
end
--[[
Add rows for book stuff
]]
if ret:paramDefined('book_author') then
ret:pad(20)
:addRow{
{ tag = 'th', content = 'Book', class = 'infobox-subheader', colspan = '20' },
}
:pad(20)
:addRow{
{ tag = 'th', content = 'Author', colspan = '7' },
{ tag = 'argd', content = 'book_author', colspan = '13' },
}
end
ret:finish()
return ret:tostring()
end
return p