Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
无编辑摘要
无编辑摘要
 
(未显示3个用户的3个中间版本)
第13行: 第13行:
 
local tablestyle = args.tablestyle or ''
 
local tablestyle = args.tablestyle or ''
 
local sprite = require( 'Module:Sprite' ).sprite
 
local sprite = require( 'Module:Sprite' ).sprite
local ids = mw.loadData( 'Module:Schematic/IDs' ).ids
+
local ids = mw.loadData( 'Module:Schematic/Data' ).ids
 
local titles = mw.loadData( 'Module:Schematic/Titles' )
 
local titles = mw.loadData( 'Module:Schematic/Titles' )
 
local isTable = false
 
local isTable = false
第55行: 第55行:
 
if idData then
 
if idData then
 
local image, spriteCat = sprite{
 
local image, spriteCat = sprite{
settings = 'Schematic/Settings',
+
data = 'Schematic/Data',
 
iddata = idData,
 
iddata = idData,
 
scale = size / 16
 
scale = size / 16
第73行: 第73行:
 
end
 
end
 
 
title = table.concat( title, ' over ' )
+
title = table.concat( title, '位于' )
 
layers = table.concat( layers, '' )
 
layers = table.concat( layers, '' )
 
if isTable then
 
if isTable then
第120行: 第120行:
 
'1',
 
'1',
 
link = 'Help:红石图例',
 
link = 'Help:红石图例',
title = 'Schematic help'
+
title = '帮助'
 
}
 
}
 
} ..
 
} ..

2019年3月24日 (日) 07:29的最新版本

[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道此模块的使用方法,请帮助为其创建文档页面。
local p = {}
function p.table( f )
	local args = f.args
	if args[1] == nil then
		args = f:getParent().args
	end
	local caption = args.caption or ''
	local captionstyle = args.captionstyle or ''
	local clear = args.clear or ''
	local float = args.float or ''
	local size = tonumber( args.size ) or 32
	local style = args.style or ''
	local tablestyle = args.tablestyle or ''
	local sprite = require( 'Module:Sprite' ).sprite
	local ids = mw.loadData( 'Module:Schematic/Data' ).ids
	local titles = mw.loadData( 'Module:Schematic/Titles' )
	local isTable = false
	if args[2] or '' ~= '' then
		isTable = true
	end
	local categories = {}
	
	if size ~= 32 then
		tablestyle = 'font-size:' .. size .. 'px;' .. tablestyle
	end
	
	local cols = 0
	local maxcols = 0
	local schematic = {}
	local title = ''
	for _, cell in ipairs( args ) do
		cell = mw.text.trim( cell )
		if isTable and cell ~= '-' then
			cols = cols + 1
			if cols > maxcols then
				maxcols = cols
			end
		end
		
		if cell == '' or cell == 'air' then
			if isTable then
				table.insert( schematic, '|' )
			else
				table.insert( schematic, '<br>' )
			end
		elseif isTable and cell == '-' then
			cols = 0
			
			table.insert( schematic, '|-' )
		else
			local layers = {}
			title = {}
			for layer in mw.text.gsplit( cell, '%s*+%s*' ) do
				local idData = ids[layer]
				if idData then
					local image, spriteCat = sprite{
						data = 'Schematic/Data',
						iddata = idData,
						scale = size / 16
					}
					table.insert( layers, image )
					table.insert( categories, spriteCat )
					
					if titles[layer] then
						table.insert( title, 1, titles[layer] )
					end
				else
					table.insert( layers, '<span class="text">' .. layer .. '</span>' )
				end
			end
			if args.text then
				table.insert( layers, '<span class="text">' .. args.text .. '</span>' )
			end
			
			title = table.concat( title, '位于' )
			layers = table.concat( layers, '' )
			if isTable then
				if layers ~= '' then
					layers = '| title="' .. title .. '" | <div>' .. layers .. '</div>'
				else
					layers = '|'
				end
			end
			
			table.insert( schematic, layers )
		end
	end
	
	local attr = 'class="schematic" style="' .. tablestyle .. '"'
	if isTable then
		table.insert( schematic, 1, '{|' .. attr )
		table.insert( schematic, '|}' )
	else
		if #schematic == 0 then
			table.insert( schematic, '<br>' )
		end
		table.insert( schematic, 1, '<span ' .. attr .. ' title="' .. title .. '">' )
		table.insert( schematic, '</span>' )
	end
	
	local out
	if caption ~= '' or float ~= '' then
		if float == '' then
			float = 'right'
		end
		if clear == '' then
			clear = 'none'
		end
		
		local captionwidth = maxcols * ( size + 1 ) + 1
		if captionwidth < 182 then
			captionwidth = 182
		end
		
		if not args.nohelp and mw.title.getCurrentTitle().prefixedText ~= 'Help:红石图例' then
			caption = '<span style="float:right;padding-left:0.5em">' ..
				f:expandTemplate{
					title = 'CommentSprite',
					args = {
						'1',
						link = 'Help:红石图例',
						title = '帮助'
					}
				} ..
				'</span>' .. caption
		end
		
		out = {
			'<div class="thumb t' .. float .. '" style="clear:' .. clear .. ';' .. style .. '">',
				'<div class="thumbinner" style="display:inline-block;max-width:' .. captionwidth .. 'px">\n',
					table.concat( schematic, '\n' ),
					'\n<div class="thumbcaption" style="' .. captionstyle .. '">\n' .. caption .. '</div>',
				'</div>',
			'</div>'
		}
		out = table.concat( out )
	else
		if isTable then
			out = table.concat( schematic, '\n' )
		else
			-- Inline schematic should be a single line
			out = table.concat( schematic )
		end
	end
	out = out:gsub( ' style=""', '' ):gsub( ' title=""%s*|?', '' )
	
	return out .. table.concat( categories )
end
return p