Moduł:Wskaźnik: Różnice pomiędzy wersjami

Z Minecraft Wiki Polska
Przejdź do nawigacji Przejdź do wyszukiwania
[wersja przejrzana][wersja przejrzana]
poprawki modułu (uproszczono weryfikację parametru domyślnego przy nieskonfigurowanym szablonie oraz dodano możliwość zdefiniowania argumentu "empty" celem potencjalnego dynamicznego ustawiania wykrywanej nieprawidłowej frazy znajdującej się na początku wartości)
dNie podano opisu zmian
 
(Nie pokazano 2 pośrednich wersji utworzonych przez tego samego użytkownika)
Linia 3: Linia 3:
local result = mw.text.trim(frame.args[key] or '')
local result = mw.text.trim(frame.args[key] or '')
return #result > 0 and result or nil
return #result > 0 and result or nil
end
function link(value)
return value and '[[Plik:'..value..']]'
end
end
function p.indicator(frame)
function p.indicator(frame)
local empty = give(frame, 'empty') or '{{{1}}}'
local file = give(frame, 'file')
local file = give(frame, 'file')
local text = file and '[[Plik:'..file..']]' or give(frame, 'text')
local text = link(file) or give(frame, 'text')
assert(text, 'text')
assert(text, 'text')
assert(mw.text.truncate(file or empty, #empty, '') ~= empty, 'file')
local empty = link(give(frame, 'empty') or '{{{1}}}')
assert(mw.text.truncate(text, #empty, '') ~= empty, 'file')
frame:extensionTag
frame:extensionTag
{
{
Linia 16: Linia 19:
args =
args =
{
{
name = give(frame, 'name') or tostring(os.time())
name = give(frame, 'name') or tostring(os.time()),
},
},
}
}
end
end
return p
return p

Aktualna wersja na dzień 03:34, 30 maj 2025

[ utwórz | historia | odśwież ]Dokumentacja
W tym module nie ma dokumentacji. Jeśli wiesz jak używać tego modułu, proszę, podaj odpowiednie informacje.
local p = {}
function give(frame, key)
	local result = mw.text.trim(frame.args[key] or '')
	return #result > 0 and result or nil
end
function link(value)
	return value and '[[Plik:'..value..']]'
end
function p.indicator(frame)
	local file = give(frame, 'file')
	local text = link(file) or give(frame, 'text')
	assert(text, 'text')
	local empty = link(give(frame, 'empty') or '{{{1}}}')
	assert(mw.text.truncate(text, #empty, '') ~= empty, 'file')
	frame:extensionTag
	{
		name = 'indicator',
		content = text,
		args =
		{
			name = give(frame, 'name') or tostring(os.time()),
		},
	}
end
return p