inefficient code

mail@pastecode.io avatar
unknown
lua
3 years ago
2.8 kB
3
Indexable
function showDXTiles()
    if (not isInsideArea) then
        return false
    end
    if (boost) then
        dxDrawText("BOOSTED", (sX - 406) / 2, (sY - 108) / 2, ((sX - 406) / 2) + 406, ( (sY - 108) / 2) + 108, boostcolor, 5.00, "default", "center", "center", false, false, false, false, false)
    end
    dxDrawRectangle((sX - width) / 2, (sY - 720), width, 26, white, false)
    if (table.size(tiles) == 0) then return false end
    local whatleft = cells-table.size(tiles)
    for i, v in ipairs(teams) do
        add[i] = howManyColor(owned, v)
    end
    for i, v in pairs(tiles) do
        local x, y, z = getElementPosition(v)
        local z = z+1.55
        dxDrawMaterialLine3D(x+4.5, y, z-0.95, x-4.5, y, z-0.95, dot, 9, colors[owned[tiles[tostring(i)]]], false, x, y, z)
        --dxDrawTextOnElement(v, "Tiles "..tostring(i)..", "..tostring(math.ceil(x))..", "..tostring(math.ceil(y)), 1, 160, 0, 0, 0,255, 2,"arial")
    end
    dxDrawRectangle((sX - width) / 2, (sY - 720), add[1]*5, 26, colors["red"], false)
    dxDrawRectangle(add[1]*5 + (sX - width) / 2, (sY - 720), add[2]*5, 26, colors["green"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + (sX - width) / 2, (sY - 720), add[3]*5, 26, colors["blue"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + (sX - width) / 2, (sY - 720), add[4]*5, 26, colors["yellow"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + add[4]*5 + (sX - width) / 2, (sY - 720), add[5]*5, 26, colors["pink"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + add[4]*5 + add[5]*5 + (sX - width) / 2, (sY - 720), add[6]*5, 26, colors["purple"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + add[4]*5 + add[5]*5 + add[6]*5 + (sX - width) / 2, (sY - 720), add[7]*5, 26, colors["brown"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + add[4]*5 + add[5]*5 + add[6]*5 + add[7]*5 + (sX - width) / 2, (sY - 720), add[8]*5, 26, colors["grey"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + add[4]*5 + add[5]*5 + add[6]*5 + add[7]*5 + add[8]*5 + (sX - width) / 2, (sY - 720), add[9]*5, 26, colors["orange"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + add[4]*5 + add[5]*5 + add[6]*5 + add[7]*5 + add[8]*5 + add[9]*5 + (sX - width) / 2, (sY - 720), add[10]*5, 26, colors["black"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + add[4]*5 + add[5]*5 + add[6]*5 + add[7]*5 + add[8]*5 + add[9]*5 + add[10]*5 + (sX - width) / 2, (sY - 720), add[11]*5, 26, colors["lime"], false)
    dxDrawRectangle(add[1]*5 + add[2]*5 + add[3]*5 + add[4]*5 + add[5]*5 + add[6]*5 + add[7]*5 + add[8]*5 + add[9]*5 + add[10]*5 + add[11]*5 + (sX - width) / 2, (sY - 720), add[12]*5, 26, colors["cyan"], false)
end