mNo edit summary |
mNo edit summary |
||
Line 44: | Line 44: | ||
local infobox = data.infobox(blueprint, var1, var2, varBiome, designer, visualEffect, ingame, pageName, frame) |
local infobox = data.infobox(blueprint, var1, var2, varBiome, designer, visualEffect, ingame, pageName, frame) |
||
-- Finished product |
-- Finished product |
||
− | return infobox .. " |
+ | return infobox .. "\n" .. quotation .. description .. crafting .. categories |
end |
end |
||
Revision as of 14:56, 22 February 2018
Documentation for this module may be created at Module:NewDecoPage/test/doc
local data = {}
function data.main(frame)
-- Input from template
local blueprint = frame.args['blueprint']
local var1 = frame.args['var1']
local var2 = frame.args['var2']
local biomes = frame.args['biome']
local visualEffect = frame.args['effect']
local ingame = frame.args['ingame']
local quote = frame.args['quote']
local description = frame.args['description']
local emitLight = frame.args['emitLight']
local pageName = frame.args['pageName']
local itemSet = frame.args['set']
-- ci# = Crafting Item #
-- ca# = Crafting Amount #
local values = {
frame.args['ci1'],
frame.args['ca1'],
frame.args['ci2'],
frame.args['ca2'],
frame.args['ci3'],
frame.args['ca3'],
frame.args['ci4'],
frame.args['ca4'],
frame.args['ci5'],
frame.args['ca5'],
frame.args['ci6'],
frame.args['ca6']
}
-- ra = Result Amount
local ra = frame.args['ra']
-- Expanded Template Variables
local workbench = frame:expandTemplate{title='NewDecoPage/Variable', args={Type='tool', Biome=biomes}}
local varBiome = frame:expandTemplate{title='NewDecoPage/Variable', args={Type='biome', Biome=biomes}}
local recipe = frame:expandTemplate{title='NewDecoPage/Variable', args={Type='recipe', Biome=biomes}}
-- Function variables
local crafting = data.craft(workbench, ra, values, frame)
local quotation = data.quote(quote, frame)
local designer = data.designer(blueprint)
local categories = data.category(emitLight, designer, varBiome, recipe, pageName)
local description = data.description(emitLight, workbench, pageName, itemSet)
local infobox = data.infobox(blueprint, var1, var2, varBiome, designer, visualEffect, ingame, pageName, frame)
-- Finished product
return infobox .. "\n" .. quotation .. description .. crafting .. categories
end
--Categories
function data.category(emitLight, designer, varBiome, recipe, pageName)
local result = '[[Category: Decoration]][[Category: Placeable]]'
if string.lower(emitLight) == 'yes' then
result = result .. '[[Category:Luminous]]'
end
if (designer ~= nil and designer ~= '') then
result = result .. '[[Category:' .. designer .. ']]'
end
if (varBiome ~= nil and varBiome ~= '') then
result = result .. '[[Category:' .. varBiome .. ']]'
end
if (recipe ~= nil and recipe ~= '') then
--Test if item is part of recipe item
local exclude = {}
for _, v in pairs(mw.loadData('Module:Decoration_recipes/' .. varBiome .. '/Exclude')) do
exclude[v] = true
end
if not exclude[pageName] then
result = result .. '[[Category:' .. recipe .. ']]'
end
end
return result
end
-- Crafting
function data.craft(workbench, ra, array, frame)
if (array[1] ~= nil and array[1] ~= '') then
local values = {
['tool'] = workbench,
['resultAmount'] = ra
}
--Assigns values to crafting ingrediant and amount
local count = 1
for n=1,12 do
if (array[n] ~= nil and array[n] ~= '') then
if tonumber(array[n]) == nil then
values['item'..count] = array[n]
else
values['amount'..count] = array[n]
count = count + 1
end
else
count = count + 1
end
end
return frame:preprocess('\n==Crafting==\n' .. frame:expandTemplate{title='Crafting recipe', args=values})
else
return ''
end
end
-- Quote detection
function data.quote(quote, frame)
if (quote ~= nil and quote ~= '') then
return frame:expandTemplate{title='Description', args={quote, 'Item Tooltip'}} .. '<br>'
else
return ''
end
end
--Isolate designer from blueprint
function data.designer(blueprint)
local designer = 'Trove Team'
if (blueprint ~= nil and blueprint ~= '') then
if string.find(blueprint, ']') ~= nil then
local p,q = string.find(blueprint, '%b[]')
designer = string.sub(blueprint, p + 1, q - 1)
-- exception code
exception = mw.loadData('Module:NewDecoPage/Designer')
if exception[string.lower(designer)] ~= nil then
designer = exception[string.lower(designer)]
else
designer = string.lower(designer):gsub("^%l", string.upper)
end
end
end
return designer
end
--Item infobox
function data.infobox(blueprint, var1, var2, varBiome, designer, visualEffect, ingame, pageName, frame)
-- Variation blueprints
local ids = string.lower(blueprint)
local imageData = '{{#tag:tabber|Item ={{Blueprint|name=' .. string.upper(blueprint) .. '|placeholder = ' .. pageName .. '.png}}'
if (var1 ~= nil and var1 ~= '') then
ids = ids .. '<br>' .. string.lower(var1)
imageData = imageData .. '{{!}}-{{!}}Variation1={{Blueprint|name =' .. string.upper(var1) .. '|placeholder = ' .. pageName .. '1.png}}'
if (var2 ~= nil and var2 ~= '') then
ids = ids .. '<br>' .. string.lower(var2)
imageData = imageData .. '{{!}}-{{!}}Variation2={{Blueprint|name =' .. string.upper(var2) .. '|placeholder = ' .. pageName .. '2.png}}'
end
end
-- Image tabber
if (visualEffect ~= nil and visualEffect ~= '') then
imageData = imageData .. '{{!}}-{{!}}Effect = [[File:' .. visualEffect .. '|200px]]'
end
if (ingame ~= nil and ingame ~= '') then
imageData = imageData .. '{{!}}-{{!}}Ingame = [[File:' .. ingame .. '.png|200px]]'
else
imageData = imageData .. '{{!}}-{{!}}Ingame = [[File:' .. pageName .. '_ingame.png|200px]]'
end
imageData = imageData .. '}}'
-- Remove type2 field if empty
if (varBiome ~= nil and varBiome ~= '') then
varBiome = '[[' .. varBiome .. ']]'
end
-- Inputs for Item infobox template
local values = {
['id'] = ids,
['tradeable'] = 'yes',
['type'] = '[[Decoration]]',
['type2'] = varBiome,
['placeable'] = '[[Cornerstone]] - [[Club World]]',
['designer'] = '[[:Category:' .. designer .. '|' .. designer .. ']]',
['image'] = frame:preprocess(imageData)
}
return frame:expandTemplate{title='Item infobox/test', args=values}
end
--Item desciption
function data.description(emitLight, workbench, pageName, itemSet)
-- Start of result
local result = 'The <b>' .. pageName .. '</b>' .. ' is a placable'
--Decoration is luminous
if string.lower(emitLight) == 'yes' then
result = result .. ', [[:Category:Luminous|luminous]]'
end
-- 2nd part of result
result = result .. ' [[decoration]]'
--Decoration is craftable
if (workbench ~= nil and workbench ~= '') then
result = result .. ' that is crafted through the [[' .. workbench .. ']]'
end
--Decoration is a banner
if string.find(pageName, 'Banner') ~= nil then
local i,_ = string.find(pageName, 'Banner')
if i + 7 <= string.len(pageName) then
result = result .. '. Like other decorational banners, the ' .. pageName .. ' can be combined with the'
if string.find(pageName, 'Top') ~= nil then
result = result .. ' [[' .. string.gsub(pageName, 'Top' , 'Middle') .. '|Middle]] and [[' .. string.gsub(pageName, 'Top' , 'Bottom') .. '|Bottom]]'
elseif string.find(pageName, 'Middle') ~= nil then
result = result .. ' [[' .. string.gsub(pageName, 'Middle' , 'Top') .. '|Top]] and [[' .. string.gsub(pageName, 'Middle' , 'Bottom') .. '|Bottom]]'
else
result = result .. ' [[' .. string.gsub(pageName, 'Bottom' , 'Top') .. '|Top]] and [[' .. string.gsub(pageName, 'Bottom' , 'Middle') .. '|Middle]]'
end
result = result .. ' sections to create the full banner'
end
end
result = result .. '.'
return result
end
return data