Modul:Spielwiese

Hier können kurzzeitige Code-Tests oder sonstige Spielereien durchgeführt werden.

Zu weitergehenden und dauerhaften Tests siehe Hilfe:Lua #Erprobung.


local p = {}

function p.f(frame)
	local args = frame:getParent().args
	local items = {}
	local titelPrefix = 'titel'

	for key, value in pairs(args) do
		local index = tonumber(key)
		if index then
			value = mw.text.trim(value)
			if value ~= '' then
				local titel = mw.text.trim(args[titelPrefix .. key] or '')
				if titel ~= '' then
					table.insert(items, string.format('[[%s|%s]]', value, titel))
				else
					table.insert(items, string.format('[[%s]]', value))
				end
			end
		end
	end

	if #items == 0 then
		return '<span class="error">Einbindungsfehler: Die [[Vorlage:Siehe auch|Vorlage „Siehe auch“]] benötigt immer mindestens ein Argument.</span>'
	end

	local text
	if #items == 1 then
		text = items[1]
	elseif #items == 2 then
		text = items[1] .. ' und ' .. items[2]
	else
		text = table.concat(items, ', ', 1, #items - 1)
		text = text .. ' und ' .. items[#items]
	end

	return string.format(
		'<div class="sieheauch" role="navigation" style="font-style:italic;"><span class="sieheauch-text">Siehe auch</span>: %s</div>',
		text
	)
end

function p.SteradiantPercentage(frame)
    -- Parameter akzeptieren: positions- oder namensbasiert
    local arg = frame.args[1] or frame.args["value"] or frame:getParent().args[1] or frame:getParent().args["value"]
    local normalized = mw.ustring.gsub(arg, ",", ".")
    local num = tonumber(normalized)
    if not num then
        return "<span class=\"error\">Fehler: ungültiger Wert</span>"
    end

    local result = num / (4 * math.pi)
    -- Format mit genau 3 Nachkommastellen und ein Prozentzeichen
    local formatted = string.format("%.3f", result)
    formatted = mw.ustring.gsub(formatted, "%.", ",")
    return formatted .. "%"
end


return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.