BirbAngry emoji.png
Open Beta is out on IOS/Android, PC & Mac! Play Now for Free!

Module:ItemInfobox: Difference between revisions

From Castaways Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(15 intermediate revisions by 4 users not shown)
Line 16: Line 16:
} )
} )
:addImage( args.image, args.caption )
:addImage( args.image, args.caption )
:addWikitext ( 'Common Properties' )
:addHeader ( 'Properties' )
:addRow ( 'Display Name', args.displayName )
:addRow ( 'Display Name', args.displayName )
:addRow ( 'Stackable?', args.stackable )
:addRow ( 'Stackable?', args.stackable )
   
local recipe = capiunto.create( {
title = 'Crafting Recipe'
} )
:addRow( 'Ingredients', tostring(args.recipeInput) )
:addRow( 'Output Quantity', tostring(args.recipeOutput) )
retval:addRow ('Recipe', tostring( recipe:getHtml() ))
if not args.consumable then
args.consumable = 'N/A'
end
retval:addRow ( 'Consumable?', args.consumable )
if args.recipeInput and args.recipeInput ~= '' then
retval:addHeader( 'Crafting Recipe' )
retval:addRow( 'Ingredients', args.recipeInput )
retval:addRow( 'Output Quantity', args.recipeOutput )
end
if args.tool and args.tool ~= '' then
if args.tool and args.tool ~= '' then
retval:addWikitext( 'Tool Properties' )
retval:addHeader( 'Tool Properties' )
retval:addRow ( 'Tool Type', args.tool)
retval:addRow ( 'Tool Type', args.tool)
Line 38: Line 42:
retval:addRow( 'Durability', args.durability )
retval:addRow( 'Durability', args.durability )
retval:addRow( 'Tool Multiplier', args.toolMultiplier )
retval:addRow( 'Tool Multiplier', args.toolMultiplier )
end
if args.weapon and args.weapon ~= '' then -- will be useful when weapons are useful
retval:addHeader( 'Weapon Properties' )
retval:addRow ( 'Weapon Type', args.weapon)
retval:addRow( 'Durability', args.durability )
retval:addRow( 'Damage', args.damage )
end
if args.poolType and args.poolType ~= '' then
retval:addHeader( 'Fishing Properties' )
retval:addRow ( 'Pool Type', args.poolType )
retval:addRow ( 'Catch Chance', args.catchChance )
end
if args.food and args.food ~= '' then
retval:addHeader( 'Food Properties' )
retval:addRow ( 'Food Type', args.food)
retval:addRow ( 'Hunger Restored', args.hungerRestored)
end
end



Latest revision as of 09:02, 21 November 2022

Documentation for this module may be created at Module:ItemInfobox/doc

local capiunto = require 'capiunto'

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local headerStyle
	if args.headerstyle and args.headerstyle ~= '' then
		headerStyle = string.format('background-color:%s;', args.headerstyle)
	else
		headerStyle = 'background-color:grey;'
	end
	local retval = capiunto.create( {
		title = tostring(mw.title.getCurrentTitle()),
		headerStyle = headerStyle
	} )
	:addImage( args.image, args.caption )
	:addHeader ( 'Properties' )
	:addRow ( 'Display Name', args.displayName )
	:addRow ( 'Stackable?', args.stackable )
	
	if not args.consumable then
		args.consumable = 'N/A'
	end
	
	retval:addRow ( 'Consumable?', args.consumable )
	
	if args.recipeInput and args.recipeInput ~= '' then
		retval:addHeader( 'Crafting Recipe' )
		retval:addRow( 'Ingredients', args.recipeInput )
		retval:addRow( 'Output Quantity', args.recipeOutput )
	end
	
	if args.tool and args.tool ~= '' then
		retval:addHeader( 'Tool Properties' )
		retval:addRow ( 'Tool Type', args.tool)
		
		if args.toolEffectiveOn and args.toolEffectiveOn ~= '' then
			retval:addRow ( 'Effective On', args.toolEffectiveOn )
		end
		
		retval:addRow( 'Durability', args.durability )
		retval:addRow( 'Tool Multiplier', args.toolMultiplier )
	end
	
	if args.weapon and args.weapon ~= '' then -- will be useful when weapons are useful
		retval:addHeader( 'Weapon Properties' )
		retval:addRow ( 'Weapon Type', args.weapon)
		retval:addRow( 'Durability', args.durability )
		retval:addRow( 'Damage', args.damage )
	end
	
	if args.poolType and args.poolType ~= '' then
		retval:addHeader( 'Fishing Properties' )
		retval:addRow ( 'Pool Type', args.poolType )
		retval:addRow ( 'Catch Chance', args.catchChance )
	end
	
	if args.food and args.food ~= '' then
		retval:addHeader( 'Food Properties' )
		retval:addRow ( 'Food Type', args.food)
		retval:addRow ( 'Hunger Restored', args.hungerRestored)
	end

	return retval
end

return p