
function ItemSelector:SetSlotTexture(slot_id, item, quality)
    local slot = self["Slot"..(slot_id+1)];
    if (not slot) then return end;
    
    local file;
    local u1, u2, v1, v2;
    local a = 1.0;
    local r = 1.0;
    local g = 1.0;
    local b = 1.0;
    
    if (item < 256) then
        file = "Textures/terrain.png";
        
        u1, v1, u2, v2 = GetBlockUV(item);
        
        if (item == 18 or item == 2) then
            a = 1.0; r = 0.6; g = 1.0; b = 0.4;
        end
        
    elseif (item == 256) then
        slot:SetTexture("");
        return;
    
    elseif (item < 261) then
        file = "Textures/items.png";
        
        u1 = (quality-1)/16.0;
        v1 = 4.0/16.0 + (item-257)/16.0;
        
        u2 = u1 + 1.0/16.0;
        v2 = v1 + 1.0/16.0;
    
    else
        Log("Warning : ItemSelector : no texture defined for item "..item.." (quality : "..quality..")");
        return;
        
    end
    
    slot:SetTexture(file);
    slot:SetTexCoord(u1, u2, v1, v2);
    slot:SetVertexColor(r, g, b, a);
end
