×
Einen neuen Artikel erstellen
Schreibe den Seitennamen hierhin:
Wir haben derzeit 9.055 Artikel auf Vaultpedia. Gib deinen Artikelnamen oberhalb von oder klicke auf einen der unten stehenden Titel und beginne zu schreiben! ein



    Vaultpedia
    9.055Artikel

    Modul:Util: Unterschied zwischen den Versionen

    Tritt unserem Discord bei und informiere dich auf unserem Twitter-Kanal über die aktuellsten Themen rund um Fallout!
    Donnerkiesel (Diskussion | Beiträge)
    Die Seite wurde neu angelegt: „-- Various utility functions local p = {} -- return pagename without any disambiguation title function p.corename(frame) local result = mw.ustring.gsub(m…“
     
    Huu.Psii (Diskussion | Beiträge)
    Keine Bearbeitungszusammenfassung
     
    (2 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt)
    Zeile 1: Zeile 1:
    -- Various utility functions
    -- Quelle: https://fallout.fandom.com/wiki/Module:Util


    local p = {}
    local util = {}


    -- return pagename without any disambiguation title
    function util.corename(frame, title)
    function p.corename(frame)
    if frame ~= nil and util.exists(frame.args[1]) then
         local result = mw.ustring.gsub(mw.title.getCurrentTitle().subpageText, '%s%(.*', '')
        result = mw.ustring.gsub(frame.args[1], '%s%(.*', '')
        return result
         else
        if util.exists(title) then
        result =  mw.ustring.gsub(title, '%s%(.*', '')
        else
        result = mw.ustring.gsub(mw.title.getCurrentTitle().subpageText, '%s%(.*', '')
        end
    end
    return result
    end
    end


    return p
    function util.exists(object, child)
    if object ~= nil and object ~= '' then
    if child ~= nil then
    if object[child] ~= nil and object[child] ~= '' then
    return true
    else
    return false
    end
    else
    return true
    end
    else
    return false
    end
    end
     
    function util.trim(s)
      return s:match'^()%s*$' and '' or s:match'^%s*(.*%S)'
    end
     
    function util.default(data, default)
    if util.exists(data) then
    return data
    else
    return default
    end
    end
     
    return util

    Aktuelle Version vom 12. Oktober 2024, 22:08 Uhr

    Die Dokumentation für dieses Modul kann unter Modul:Util/Doku erstellt werden

    -- Quelle: https://fallout.fandom.com/wiki/Module:Util
    
    local util = {}
    
    function util.corename(frame, title)
    	if frame ~= nil and util.exists(frame.args[1]) then
        	result = mw.ustring.gsub(frame.args[1], '%s%(.*', '')
        else
        	if util.exists(title) then
        		result =  mw.ustring.gsub(title, '%s%(.*', '')
        	else
        		result = mw.ustring.gsub(mw.title.getCurrentTitle().subpageText, '%s%(.*', '')
        	end
    	end
    	return result
    end
    
    function util.exists(object, child)
    	if object ~= nil and object ~= '' then
    		if child ~= nil then
    			if object[child] ~= nil and object[child] ~= '' then
    				return true
    			else
    				return false
    			end
    		else
    			return true
    		end
    	else
    		return false
    	end
    end
    
    function util.trim(s)
       return s:match'^()%s*$' and '' or s:match'^%s*(.*%S)'
    end
    
    function util.default(data, default)
    		if util.exists(data) then
    		return data
    	else
    		return default
    	end
    end
    
    return util