Module:NewDecoPage

local data = {} function data.main(frame) --Sets Language to English local lang = mw.language.getContentLanguage -- 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'] -- Modified Page Name for disambiguous deco local Modname = pageName if string.find(pageName, ')') ~= nil then       local p,_ = string.find(pageName, '%b')        Modname = string.sub(pageName, 1, p - 2)    end    -- 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, lang)    local quotation = data.quote(quote, frame)    local designer = data.designer(blueprint)    local categories = data.category(emitLight, designer, varBiome, recipe, pageName)    if (description == nil or description == '') then        description = data.description(emitLight, workbench, pageName, itemSet, Modname) end local infobox = data.infobox(blueprint, var1, var2, varBiome, designer, visualEffect, ingame, pageName, Modname, frame) -- Finished product return infobox .. quotation .. description .. crafting .. categories end --Categories function data.category(emitLight, designer, varBiome, recipe, pageName) local result = '' if string.lower(emitLight) == 'yes' then result = result .. ''   end if (designer ~= nil and designer ~= '') then result = result .. ''   end if (varBiome ~= nil and varBiome ~= '') then result = result .. ''   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 .. ''       end end return result end -- Crafting function data.craft(workbench, ra, array, frame, language) 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] = language:formatNum(tonumber(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'}} .. ' '   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, Modname, frame) -- Variation blueprints local ids = string.lower(blueprint) local imageData = '' -- Remove type2 field if empty if (varBiome ~= nil and varBiome ~= '') then -- Changes type2 link to category link if in the table local seasons = { ['Geode'] = 'Geode', ['Spring'] = 'Spring', ['Summer'] = 'Summer', ['Winter'] = 'Winter' }       if seasons[varBiome] ~= nil then varBiome =  .. varBiome ..  else varBiome =  .. varBiome ..  end end -- Inputs for Item infobox template local values = { ['name'] = Modname, ['id'] = ids, ['tradeable'] = 'yes', ['type'] = 'Decoration', ['type2'] = varBiome, ['placeable'] = 'Cornerstone - Club World', ['designer'] =  .. designer .. , ['image'] = frame:preprocess(imageData) }   return frame:expandTemplate{title='Item infobox', args=values} .. '\n' end

-- Item desciption function data.description(emitLight, workbench, pageName, itemSet, Modname) -- Start of result local result = 'The  .. Modname .. ' .. ' is a placable' -- Decoration is luminous if string.lower(emitLight) == 'yes' then result = result .. ', 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 local geode = false local currentSect = nil local sections = { 'Top', 'Bottom' }   if string.find(pageName, 'Banner') ~= nil then local i,_ = string.find(pageName, 'Banner') if i + 7 <= string.len(pageName) then -- If Geode banner if string.find(pageName, 'Spire Banner') ~= nil then geode = true end if geode then table.insert(sections, 2, 'Lower Middle') table.insert(sections, 2, 'Upper Middle') result = result .. '. Like other Geode spire banners, the ' .. pageName .. ' can be combined with the' else table.insert(sections, 2, 'Middle') result = result .. '. Like other decorational banners, the ' .. pageName .. ' can be combined with the' end -- Determines which section the banner is           for n, part in ipairs(sections) do                    if string.find(pageName, part) ~= nil then currentSect = sections[n] table.remove(sections, n)                       break end end -- Generates links to other parts if geode then result = result .. ' ' .. sections[1] .. ', ' .. sections[2] .. ', and ' .. sections[3] .. '' else result = result .. ' ' .. sections[1] .. ' and ' .. sections[2] .. '' end result = result .. ' sections to create the full banner' end end result = result .. '.'   return result end return data