Minecraft Wiki
Нет описания правки
мНет описания правки
 
(не показаны 22 промежуточные версии 3 участников)
Строка 8: Строка 8:
 
args = require("Модуль:ProcessArgs").norm(args)
 
args = require("Модуль:ProcessArgs").norm(args)
 
 
local i = 0
+
local i = #args
  +
for index, arg in ipairs(args) do
 
  +
local dub = {}
i = i + 1
 
  +
if args.dub~=nil then
  +
for v in mw.text.gsplit( args.dub or '', '%s*;%s*' ) do
  +
h = mw.text.split( v, '%s*,%s*' )[2]
  +
dub[tonumber(mw.text.split( v, '%s*,%s*' )[1])] = h
 
i = i + h - 1
 
end
 
end
 
end
  +
 
 
local result = {}
 
local result = {}
 
table.insert(result, '<table cellpadding="2" cellspacing="0" style="line-height: 36px; padding-right: 20px; padding-bottom: 20px">')
 
table.insert(result, '<table cellpadding="2" cellspacing="0" style="line-height: 36px; padding-right: 20px; padding-bottom: 20px">')
Строка 20: Строка 26:
 
 
 
for index, arg in ipairs(args) do
 
for index, arg in ipairs(args) do
  +
local k = 1
 
 
if dub[#args-index+1] ~= nil then
table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слой ' .. i .. '</td><td>')
 
  +
k = dub[#args-index+1]
 
 
end
 
if k == 1 then
 
table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слой ' .. i .. '</td><td>')
  +
else
  +
table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слои ' .. i - k + 1 .. '-' .. i .. '</td><td>')
  +
end
 
local sloy = {}
 
local sloy = {}
 
sloy = mw.text.split(arg,',')
 
sloy = mw.text.split(arg,',')
 
local mass = {}
 
local mass = {}
 
local massb = {}
 
local massb = {}
local colmax = 0
+
local maxw = #sloy
 
for row = 1, #sloy do
 
for row = 1, #sloy do
 
local line = sloy[row]
 
local line = sloy[row]
local s = mw.ustring.gsub(line, '%^', '')
+
maxw = math.max(maxw, mw.ustring.len(mw.ustring.gsub(line, '%^', '')) )
colmax = math.max(colmax, mw.ustring.len(s) )
 
 
mass[row] = {}
 
mass[row] = {}
 
massb[row] = {}
 
massb[row] = {}
Строка 48: Строка 59:
 
end
 
end
   
for i2 = 1, colmax + #sloy - 1 do
+
for i2 = 1, maxw + #sloy - 1 do
for n = 1, i2 do
+
for n = math.max(1,i2+1-maxw), math.min(i2,maxw) do
if mass[n] ~= nil then
+
if mass[n] == nil then
if i2+1-n <= colmax then
+
argChar = '-'
argChar = mass[n][i2+1-n]
+
elseif mass[n][i2+1-n] == nil then
if argChar == nil then argChar = '-' end
+
argChar = '-'
  +
else
if argChar ~= '-' then
 
  +
argChar = mass[n][i2+1-n]
table.insert(result, '<span style="position: absolute; margin-left: -20px; margin-top: 10px; z-index: -1">[[Файл:Сетка изометрия.png|link=]]</span>')
 
end
+
end
local slotArgs = {}
+
local slotArgs = {}
if args["M" .. argChar] then
+
if (argChar ~= '-') then
 
table.insert(result, '<span class="isometry" style="position: absolute; margin-left: -20px; margin-top: 10px; z-index: 1">[[Файл:Сетка изометрия.png|link=]]</span>')
slotArgs["мод"] = args["Мод"]
 
  +
if (argChar ~= '_') then
end
 
slotArgs[1] = (args["M" .. argChar] or '') .. (args[argChar] or '')
+
slotArgs["мод"] = args["Мод"]
slotArgs["класс"] = "invslot-plain"
+
slotArgs[1] = (args[argChar] or '')
if massb[n][i2+1-n] ~= nil then
 
slotArgs["стиль"] = "outline: 2px solid " .. ({"red", "blue", "green"})[massb[n][i2+1-n]]
 
end
 
table.insert(result, invSlot(slotArgs))
 
table.insert(result, "<br>")
 
 
end
 
end
  +
else
 
slotArgs[1] = ''
 
end
 
end
  +
slotArgs["класс"] = "invslot-plain"
  +
if massb[n] ~= nil then
  +
if massb[n][i2+1-n] ~= nil then
 
slotArgs["стиль"] = "position: relative; z-index:2; outline: 2px solid " .. ({"red", "blue", "green"})[massb[n][i2+1-n]]
  +
else
  +
slotArgs["стиль"] = "position: relative; z-index:2;"
  +
end
  +
end
 
table.insert(result, invSlot(slotArgs))
 
table.insert(result, "<br>")
 
end
 
end
 
table.insert(result, '</td><td>')
 
table.insert(result, '</td><td>')
 
end
 
end
 
 
table.insert(result, "</td></tr>\n")
 
table.insert(result, "</td></tr>\n")
i = i - 1
+
i = i - k
 
end
 
end
 
table.insert(result, "</table>")
 
table.insert(result, "</table>")

Текущая версия от 10:34, 6 июня 2021

[создать | история | обновить]Документация
У этого модуля нет документации. Если вы знаете, как использовать этот модуль, пожалуйста, добавьте соответствующую информацию.
p = {}

p.structure = function(f)
	local args = f.args or f
	if f == mw.getCurrentFrame() and args[1] == nil then
		args = f:getParent().args
	end
	args = require("Модуль:ProcessArgs").norm(args)
	
	local i = #args

	local dub = {}
	if args.dub~=nil then
		for v in mw.text.gsplit( args.dub or '', '%s*;%s*' ) do
			h = mw.text.split( v, '%s*,%s*' )[2]
			dub[tonumber(mw.text.split( v, '%s*,%s*' )[1])] = h
			i = i + h - 1
		end
	end

	local result = {}
	table.insert(result, '<table cellpadding="2" cellspacing="0" style="line-height: 36px; padding-right: 20px; padding-bottom: 20px">')
	local border = 0
	
	local invSlot = require("Модуль:Инвентарный слот").slot
	
	for index, arg in ipairs(args) do
		local k = 1
		if dub[#args-index+1] ~= nil then 
			k = dub[#args-index+1]
		end
		if k == 1 then
			table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слой ' .. i .. '</td><td>')
		else
			table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слои ' .. i - k + 1 .. '-' .. i .. '</td><td>')
		end
		local sloy = {}
		sloy = mw.text.split(arg,',')
		local mass = {}
		local massb = {}
		local maxw = #sloy
		for row = 1, #sloy do
			local line = sloy[row]
			maxw = math.max(maxw, mw.ustring.len(mw.ustring.gsub(line, '%^', '')) )
			mass[row] = {}
			massb[row] = {}
			for i2 = 1, mw.ustring.len(line) do
				local argChar = mw.ustring.sub(line, i2, i2)
				if argChar == '^' then
					border = border + 1
				else
					table.insert(mass[row],argChar)
					if border ~= 0 then
						massb[row][#mass[row]] = border
						border = 0
					end
				end
			end
		end

		for i2 = 1, maxw + #sloy - 1 do
			for n = math.max(1,i2+1-maxw), math.min(i2,maxw) do
				if mass[n] == nil then
					argChar = '-'
				elseif mass[n][i2+1-n] == nil then
					argChar = '-'
				else
					argChar = mass[n][i2+1-n]
				end
				local slotArgs = {}
				if (argChar ~= '-') then
					table.insert(result, '<span class="isometry" style="position: absolute; margin-left: -20px; margin-top: 10px; z-index: 1">[[Файл:Сетка изометрия.png|link=]]</span>')
					if (argChar ~= '_') then
						slotArgs["мод"] = args["Мод"]
						slotArgs[1] = (args[argChar] or '')
					end
				else
					slotArgs[1] = ''
				end
				slotArgs["класс"] = "invslot-plain"
				if massb[n] ~= nil then
					if massb[n][i2+1-n] ~= nil then
						slotArgs["стиль"] = "position: relative; z-index:2; outline: 2px solid " .. ({"red", "blue", "green"})[massb[n][i2+1-n]]
					else
						slotArgs["стиль"] = "position: relative; z-index:2;"
					end
				end
				table.insert(result, invSlot(slotArgs))
				table.insert(result, "<br>")
			end
			table.insert(result, '</td><td>')
		end
		table.insert(result, "</td></tr>\n")
		i = i - k
	end
	table.insert(result, "</table>")
	return table.concat(result)
end

return p