Warframe Wiki
Advertisement

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:I/opis

local moduleIcon = {}

local IData = mw.loadData( 'Moduł:I/data' )

function createIcon(icon, link, text, size)
    if( text == nil or text == '' ) then
        return '[[File:'..icon..'|'..size..'px|link='..link..']]'
    else 
        return '[[File:'..icon..'|'..size..'px|link='..link..']] [['..link..'|'..text..']]'
    end
end

function moduleIcon.Icon(frame)

    local iconName = frame.args[1]
    local text = frame.args[2]
    local size = frame.args.size
    local color = frame.args.color
    local image

    if( IData[iconName] == nil ) then
        return "<span style='color: red;'>Ikona <span style='font-weight:900;'>".. iconName .."</span> nie istnieje</span>[[Kategoria:Nieistniejąca ikona]]"
    end
    
    if( color == nil or color == '' ) then
        color = black;
    end
    
    if( type(IData[iconName].image) == table ) then
        if( IData[iconName].image[color] == nil ) then
            return "<span style='color: red;'>Kolor <span style='font-weight:900;'>".. color .."</span> nie istnieje</span>[[Kategoria:Nieistniejąca ikona]]"
        else 
            image = IData[iconName].image[color]
        end
    else 
        image = IData[iconName].image
    end

    if( size == nil or size == '' ) then
        size = IData[iconName].size
    end

    return createIcon(IData[iconName].image, IData[iconName].link, text, size)

end

function moduleIcon.Ryba( frame )
    local iname = frame.args[1]        
    local textExist = frame.args[2]
    local size = frame.args.size
    local icon = ''
    local link = ''

    if IData['Ryba'][iname] == nil then
        return "<span style='color:red;'>Niepoprawna nazwa "..iname.."</span>"
    else
        icon = IData["Ryba"][iname]["image"]
        link = IData["Ryba"][iname]["link"]
        if (size == nil or size == '') then
            size = 'x32'                                 
        end
        if (textExist == 'text' or textExist == 'Text') then
            return '[[File:'..icon..'|'..size..'px|link='..link..']] [['..link..'|'..iname..']]'
        else
            return '[[File:'..icon..'|'..size..'px|link='..link..']]'
        end
    end
end

function moduleIcon.Item(frame)
    local iname = frame.args[1]
    local textExist = frame.args[2]
    local link = ''
    local icon = ''
    local size = frame.args.size
    
    if IData['Item'][iname] == nil then
        return "<span style='color:red;'>Niepoprawna nazwa "..iname.."</span>"
    else
        icon = IData['Item'][iname]['image']
        link = IData['Item'][iname]['link']
        if (size == nil or size == '') then
            size = 'x30'
        end
        if (textExist == 'text' or textExist == 'Text') then
            return '[[File:'..icon..'|'..size..'px|link='..link..']] [['..link..'|'..iname..']]'
        else
            return '[[File:'..icon..'|'..size..'px|link='..link..']]'
        end
    end
end

function moduleIcon.Przedmiot(frame)
    local iname = frame.args[1]
    local textExist = frame.args[2]
    local link = ''
    local icon = ''
    local size = frame.args.size
    
    if IData['Przedmiot'][iname] == nil then
        return "<span style='color:red;'>Niepoprawna nazwa "..iname.."</span>"
    else
        icon = IData['Przedmiot'][iname]['image']
        link = IData['Przedmiot'][iname]['link']
        if (size == nil or size == '') then
            size = 'x30'
        end
        if (textExist == 'text' or textExist == 'Text') then
            return '[[File:'..icon..'|'..size..'px|link='..link..']] [['..link..'|'..iname..']]'
        else
            return '[[File:'..icon..'|'..size..'px|link='..link..']]'
        end
    end
end

function moduleIcon.Proc(frame)
    local iname = frame.args[1]
    local textExist = frame.args[2]
    local color = frame.args[3]
    local size = frame.args.size
    
    return moduleIcon.proc(iname, textExist, color, size)
end

function moduleIcon.proc(iname, textExist, color, size)
    local link = ''
    local text = ''
    local textColor = ''
    local fr = iname:sub(1,1)
    
    if (fr == 'M' or fr == 'W' or fr == 'T') then
       fr = iname:sub(1,2)
    end
    
    if string.byte(fr,1) == 197 then
        fr = '197' 
    end
    
    if IData['Proc'][fr] == nil then
        return "<span style='color:red;'>Niepoprawna nazwa "..fr.."</span>"
    else 
        link = IData['Proc'][fr]['link']
        if color == 'white' then
            image = IData['Proc'][fr]['image'][2]
        else
            image = IData['Proc'][fr]['image'][1]
        end
        if (size == nil or size == '') then
            size = 'x18'
        end
        if (textExist =='text' or textExist == 'Text') then
            textColor = IData['Proc'][fr]['color']
            text = iname
            return '[[File:'..image..'|link='..link..'|'..size..'px]] [['..link..'|<span style=\"color:'..textColor..';\">'..text..'</span>]]'
        end
        return '[[File:'..image..'|link='..link..'|'..size..'px]]'
    end
end

function moduleIcon.Pol(frame)
    local iname = frame.args[1]
    local size = frame.args.size
    
    return moduleIcon.pol(iname, size)
end

 function moduleIcon.pol(iname, size)
    if IData['Pol'][iname] == nil then
        return "<span style='color:red;'>Niepoprawna nazwa "..iname.."</span>"
    else
        if(size == nil or size == '') then
            size = 'x20'
        end
        return '[[File:'..IData['Pol'][iname]..'|link=Polaryzacja|'..size..'px]]'
    end
end

function moduleIcon.Prime(frame)
    local name = frame.args[1]
    local text = frame.args[2]
    local imgSize = frame.args.size
    
    local primeException = {
        ['Forma'] = true,   
    }
    
    local primeTitle = ' Prime'
    
    if IData['Prime'][name] == nil then
        return "Nieznany przedmiot"
    else
        
        if( primeException[name] == true ) then 
            primeTitle = '' 
        end
        
        icon = IData['Prime'][name]['icon']
        link = IData['Prime'][name]['link']
        
        if(size == nil or size == '') then
            size = 'x32'
        end
        
        if( part ~= nil and part ~= '' ) then
            part = ' '..part
        end
        
        if( text == nil or text == '' ) then
            return '[[File:'..icon..'|link='..link..'|'..size..'px]]'
        else 
            return '[[File:'..icon..'|link='..link..'|'..size..'px]] [['..link..'|'..name..''..primeTitle..''..part..']]'
        end
        
    end
    
end

function moduleIcon.SubPrime( name, part, size )
    local icon
    local link
    
    local primeException = {
        ['Forma'] = true,   
    }
    
    local primeTitle = 'Prime '
    
    if IData['Prime'][name] == nil then
        return "Nieznany przedmiot"
    else
        
        
        if( primeException[name] == true ) then 
            primeTitle = '' 
        end
        
        icon = IData['Prime'][name]['icon']
        link = IData['Prime'][name]['link']
        
        if(size == nil or size == '') then
            size = 'x32'
        end
        return '[[File:'..icon..'|link='..link..'|'..size..'px]] [['..link..'|'..name..' '..primeTitle..''..part..']]'
        
    end
end

function moduleIcon.Resource(frame)
    local iname = frame.args[1]
    local textExist = frame.args[2]
    local size = frame.args.size
    local icon
    local link
    
    if IData['Resource'][iname] == nil then
        return ""
    else
        icon = IData['Resource'][iname]['icon']
        link = IData['Resource'][iname]['link']
        if(size == nil or size == '') then
            size = 'x32'
        end
        if(textExist == 'text' or textExist == 'Text') then
            return '[[File:'..icon..'|link='..link..'|'..size..'px]] [['..link..'|'..iname..']]'
        else
            return '[[File:'..icon..'|link='..link..'|'..size..'px]]'
        end
    end
end

function moduleIcon.Surowiec(frame)
    local iname = frame.args[1]
    local textExist = frame.args[2]
    local size = frame.args.size
    local icon
    local link
    
    if IData['Surowiec'][iname] == nil then
        return ""
    else
        icon = IData['Surowiec'][iname]['icon']
        link = IData['Surowiec'][iname]['link']
        if(size == nil or size == '') then
            size = 'x32'
        end
        if(textExist == 'text' or textExist == 'Text') then
            return '[[File:'..icon..'|link='..link..'|'..size..'px]] [['..link..'|'..iname..']]'
        else
            return '[[File:'..icon..'|link='..link..'|'..size..'px]]'
        end
    end
end

function moduleIcon.Faction(frame)
    local iname = frame.args[1]
    local size = frame.args.size
    local textExist = frame.args[2]
    local name = iname:sub(1,1)
    local link
    local color = frame.args[3]
    local icon
    
    if( name == 'S' ) then
        name = iname:sub(1,2)
    else 
        if(string.byte(name,1) == 197) then
            name = '197'
        end
    end
    
    if IData['Faction'][name] == nil then
        return "<span style='color:red;'>Niepoprawna nazwa "..name.."</span>"
    else
        if(color == nil or color == '') then
            icon = IData['Faction'][name]['icon'][1]
        else
            icon = IData['Faction'][name]['icon'][2]
        end
        link = IData['Faction'][name]['link']
        if(size == nil or size == '') then
            size = 'x20'
        end
        if(textExist == 'text' or textExist == 'Text') then
            return '[[File:'..icon..'|link='..link..'|'..size..'px]] [['..link..'|'..iname..']]'
        else
            return '[[File:'..icon..'|link='..link..'|'..size..'px]]'
        end
    end
end

function moduleIcon.Frakcja(frame)
    local iname = frame.args[1]
    local size = frame.args.size
    local textExist = frame.args[2]
    local name = mw.ustring.sub(iname,1,1)
    local link
    local color = frame.args[3]
    local icon
    
    if( name == 'S' ) then
        name = mw.ustring.sub(iname,1,2)
    end
    
    if IData['Frakcja'][name] == nil then
        return "<span style='color:red;'>Niepoprawna nazwa "..name.."</span>"
    else
        if(color == nil or color == '') then
            icon = IData['Frakcja'][name]['icon'][1]
        else
            icon = IData['Frakcja'][name]['icon'][2]
        end
        link = IData['Frakcja'][name]['link']
        if(size == nil or size == '') then
            size = 'x20'
        end
        if(textExist == 'text' or textExist == 'Text') then
            return '[[File:'..icon..'|link='..link..'|'..size..'px]] [['..link..'|'..iname..']]'
        else
            return '[[File:'..icon..'|link='..link..'|'..size..'px]]'
        end
    end
end

function moduleIcon.Fokus(frame)
    local iname = frame.args[1]
    local size = frame.args.size
    local textExist = frame.args[2]
    local color = frame.args[3]
    local typeOf = frame.args.typ
    local icon
    
    if( IData['Fokus'][iname] == nil) then
        return "<span style='color:red;'>Niepoprawna nazwa "..iname.."</span>"
    else 
        if(color == nil or color =='' ) then
            color = false
        else
            color = true
        end
        if(typeOf == nil or typeOf == '') then
            typeOf = false
        else
            typeOf = true
        end
        if(typeOf) then
            if(color) then
                icon = IData['Fokus'][iname]['pattern'][2]
            else
                icon = IData['Fokus'][iname]['pattern'][1]
            end
        else
            if(color) then
                icon = IData['Fokus'][iname]['icon'][2]
            else
                icon = IData['Fokus'][iname]['icon'][1]
            end
        end
        if(size == nil or size == '') then
            size = 'x20'
        end
        if(textExist == 'text' or textExist == 'Text') then
            return '[[File:'..icon..'|link=Fokus|'..size..'px]] [[Fokus|'..iname..']]'
        else 
            return '[[File:'..icon..'|link=Fokus|'..size..'px]]'
        end
    end
end

return moduleIcon
Advertisement