Minecraft Wiki
Нет описания правки
мНет описания правки
 
(не показано 30 промежуточных версий 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
table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слой ' .. i .. '</td><td>')
 
  +
if dub[#args-index+1] ~= nil then
 
  +
k = dub[#args-index+1]
local sloy = mw.text.split(arg,',')
 
  +
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 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]
colmax = math.max(colmax, row + mw.ustring.len(gsub(line, '^', '')) - 1 )
+
maxw = math.max(maxw, mw.ustring.len(mw.ustring.gsub(line, '%^', '')) )
 
mass[row] = {}
 
mass[row] = {}
 
massb[row] = {}
 
massb[row] = {}
Строка 36: Строка 50:
 
border = border + 1
 
border = border + 1
 
else
 
else
mass[row][i2] = argChar
+
table.insert(mass[row],argChar)
 
if border ~= 0 then
 
if border ~= 0 then
massb[row][i2] = border
+
massb[row][#mass[row]] = border
 
border = 0
 
border = 0
 
end
 
end
Строка 45: Строка 59:
 
end
 
end
   
  +
for i2 = 1, maxw + #sloy - 1 do
 
for i2 = 1, mw.ustring.len(arg) do
+
for n = math.max(1,i2+1-maxw), math.min(i2,maxw) do
 
if mass[n] == nil then
local argChar = mw.ustring.sub(arg, i2, i2)
 
if argChar == ',' then
+
argChar = '-'
  +
elseif mass[n][i2+1-n] == nil then
table.insert(result, '</td><td>')
 
 
argChar = '-'
else
 
if argChar == '^' then
 
border = border + 1
 
 
else
 
else
if argChar ~= '-' then
+
argChar = mass[n][i2+1-n]
  +
end
table.insert(result, '<span style="position: absolute; margin-left: -20px; margin-top: 10px; z-index: -1">[[Файл:Сетка изометрия.png|link=]]</span>')
 
  +
local slotArgs = {}
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 args["M" .. argChar] then
+
if (argChar ~= '_') then
 
slotArgs["мод"] = args["Мод"]
 
slotArgs["мод"] = args["Мод"]
 
slotArgs[1] = (args[argChar] or '')
 
end
 
end
  +
else
slotArgs[1] = (args["M" .. argChar] or '') .. (args[argChar] or '')
 
slotArgs["класс"] = "invslot-plain"
+
slotArgs[1] = ''
  +
end
if border ~= 0 then
 
slotArgs["стиль"] = "outline: 2px solid " .. ({"red", "blue", "green"})[border]
+
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))
 
border = 0
 
table.insert(result, "<br>")
 
 
end
 
end
 
table.insert(result, invSlot(slotArgs))
 
table.insert(result, "<br>")
 
end
 
end
 
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