匿名
未登录
创建账号
登录
The Land of StarLight
搜索
查看“模块:Crafting”的源代码
来自The Land of StarLight
命名空间
模块
讨论
更多
更多
页面操作
阅读
查看源代码
历史
←
模块:Crafting
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} local i18n = { colored = 'Colored', coloredDyes = { 'Orange Dye', 'Magenta Dye', 'Light Blue Dye', 'Yellow Dye', 'Lime Dye', 'Pink Dye', 'Gray Dye', 'Light Gray Dye', 'Cyan Dye', 'Purple Dye', 'Blue Dye', 'Brown Dye', 'Green Dye', 'Red Dye', 'Black Dye', }, categoryIngredientUsage = 'Category:含有$1的配方', categoryRecipeType = 'Category:$1的配方', categoryUpcoming = 'Category:即将到来', itemBlockOfQuartz = 'Block of Quartz', itemBoneMeal = 'Bone Meal', itemBrownMushroom = 'Brown Mushroom', itemCharcoal = 'Charcoal', itemCoal = 'Coal', itemColoredDye = 'Colored Dye', itemDye = 'Dye', itemMushroom = 'Mushroom', itemQuartzBlock = 'Quartz Block', itemRedMushroom = 'Red Mushroom', itemStone = 'Stone', itemWhiteDye = 'White Dye', moduleArgs = [[Module:ProcessArgs]], moduleRecipe = [[Module:Recipe table]], moduleSlot = [[Module:Inventory slot]], stoneVariants = { 'Stone', 'Andesite', 'Granite', 'Diorite' }, type = '合成', variantPages = { 'Andesite', 'Banner', 'Bed', 'Diorite', 'Firework Star', 'Granite', 'Log', 'Pressure Plate', 'Sand', 'Sandstone', 'Shield', 'Slab', 'Stained Glass Pane', 'Stained Glass', 'Stairs', 'Stone Bricks', 'Planks', 'Wood', 'Wool', }, } p.i18n = i18n local slot = require( i18n.moduleSlot ) local recipeTable = require( i18n.moduleRecipe ).table local cArgVals = { 'A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3' } p.cArgVals = cArgVals function p.table( f ) local args = f if f == mw.getCurrentFrame() then args = require( i18n.moduleArgs ).merge( true ) else f = mw.getCurrentFrame() end -- Automatic shapeless positioning if args[1] then args.shapeless = 1 if args[7] then args.A1 = args[1] args.B1 = args[2] args.C1 = args[3] args.A2 = args[4] args.B2 = args[5] args.C2 = args[6] if args[8] then -- ◼◼◼ ◼◼◼ -- ◼◼◼ OR ◼◼◼ -- ◼◼◼ ◼◼◻ args.A3 = args[7] args.B3 = args[8] args.C3 = args[9] if args[9] then local identical = true for i = 1, 8 do if args[i] ~= args[i + 1] then identical = false break end end if identical then args.shapeless = nil end end else -- ◼◼◼ -- ◼◼◼ -- ◻◼◻ args.B3 = args[7] end elseif args[2] then args.A2 = args[1] args.B2 = args[2] if args[5] then -- ◻◻◻ ◻◻◻ -- ◼◼◼ OR ◼◼◼ -- ◼◼◼ ◼◼◻ args.C2 = args[3] args.A3 = args[4] args.B3 = args[5] args.C3 = args[6] elseif args[4] then -- ◻◻◻ -- ◼◼◻ -- ◼◼◻ args.A3 = args[3] args.B3 = args[4] else -- ◻◻◻ ◻◻◻ -- ◼◼◻ OR ◼◼◻ -- ◻◼◻ ◻◻◻ args.B3 = args[3] end else -- ◻◻◻ -- ◻◼◻ -- ◻◻◻ args.B2 = args[1] args.shapeless = nil end for i = 1, 9 do args[i] = nil end end -- Create recipe table, and list of ingredients local out, ingredientSets = recipeTable( args, { uiFunc = 'craftingTable', type = i18n.type, ingredientArgs = cArgVals, outputArgs = { 'Output' }, } ) local title = mw.title.getCurrentTitle() if args.nocat == '1' or title.namespace ~= 0 or title.isSubpage then return out end local categories = {} local cI = 1 if args.upcoming then categories[cI] = '[[' .. i18n.categoryUpcoming .. ']]' cI = cI + 1 end if args.type then categories[cI] = '[[' .. i18n.categoryRecipeType:gsub( '%$1', args.type ) .. ']]' cI = cI + 1 end if args.ignoreusage ~= '1' then -- Create ingredient categories for DPL local usedNames = {} local function addName( name ) if not usedNames[name] then -- redundant with most current code, but not with all, and might prevent other issues categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', name ) .. ']]' cI = cI + 1 usedNames[name] = true end end for _, ingredientSet in pairs( ingredientSets ) do for _, ingredient in pairs( ingredientSet ) do local name = ingredient.name if not ingredient.mod and not usedNames[name] and name ~= title.text then -- List each dye individually as they have their own pages if name == 'Any ' .. i18n.itemDye or name == 'Matching ' .. i18n.itemDye or name == 'Any ' .. i18n.itemColoredDye or name == 'Matching ' .. i18n.itemColoredDye then if not name:find( i18n.colored ) then addName( i18n.itemWhiteDye ) end for _, dye in pairs( i18n.coloredDyes ) do addName( dye ) end -- List stone variants individually as they have their own pages elseif name == 'Any ' .. i18n.itemStone or name == 'Matching ' .. i18n.itemStone then for _, stone in pairs( i18n.stoneVariants ) do addName( stone ) end else -- Merge item variants which use a single page if name == 'Any ' .. i18n.itemMushroom or name == 'Matching ' .. i18n.itemMushroom or name == i18n.itemRedMushroom or name == i18n.itemBrownMushroom then name = i18n.itemMushroom elseif name == i18n.itemCharcoal then name = i18n.itemCoal elseif name:find( ' ' .. i18n.itemQuartzBlock .. '$' ) then name = i18n.itemBlockOfQuartz else for _, variant in pairs( i18n.variantPages ) do if name:find( ' ' .. variant .. '$' ) then name = variant break end end -- Remove prefixes for _, prefix in pairs( slot.i18n.prefixes ) do if name:find( '^' .. prefix .. ' ' ) then name = name:gsub( '^' .. prefix .. ' ', '' ) break end end end -- handle "A or B" names local orA, orB = name:match("(.-) or (.+)") -- if orA then -- addName( orA ) -- addName( orB ) -- else -- addName( name ) -- end end end end end end return out, table.concat( categories, '' ) end return p
本页使用的模板:
模块:Crafting/doc
(
查看源代码
)
返回
模块:Crafting
。
导航
快速跳转
TLSL(wiki首页)
- StarLight-Server
奇怪的折跃门
活跃玩家
重要领地合集
小黑屋
SLS官网
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志