All pastes #580237 Raw Edit

Stuff

public lua v1 · immutable
·published 2007-06-21 00:53 UTC
rendered paste body
function widget:GetInfo()  return {    name      = "XPicons",    desc      = "blabla",    author    = "q",    date      = "today",    license   = "GNU GPL, v2 or later",    layer     = 5,    enabled   = false  --  loaded by default?  }end----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------local pos          = {} -- unit positionlocal rect         = {} -- rectanglefor i = 1,4 do          --rectangle points  rect[i]          = {}endlocal tex          = {} --texture coordinatestex[1]             = {0, 0} tex[2]             = {0, 1}tex[3]             = {1, 1}tex[4]             = {1, 0}local myAllyTeamID = Spring.GetMyAllyTeamID()----------------------------------------------------------------------------------------------------------------------------------------------------------------------------Speed-upslocal gl                   = gllocal IsUnitVisible        = Spring.IsUnitVisiblelocal GetUnitPosition      = Spring.GetUnitPositionlocal GetUnitDefID         = Spring.GetUnitDefIDlocal GetUnitDefDimensions = Spring.GetUnitDefDimensionslocal GetCameraVectors     = Spring.GetCameraVectorslocal GetUnitExperience    = Spring.GetUnitExperiencelocal GetUnitAllyTeam      = Spring.GetUnitAllyTeam--------------------------------------------------------------------------------------------------------------------------------------------------------------------------function widget:DrawWorld()  local allUnits = Spring.GetAllUnits()  for _,unitID in ipairs(allUnits) do    if (IsUnitVisible(unitID)) then      local allyTeamID = GetUnitAllyTeam(unitID)      if (allyTeamID == myAllyTeamID) then                local cam = Spring.GetCameraVectors()        local unitDefID = GetUnitDefID(unitID)        local h = GetUnitDefDimensions(unitDefID).height                local xp = GetUnitExperience(unitID)        local rank = math.min(math.floor(xp*10)+1, 11)                pos[1], pos[2], pos[3] = GetUnitPosition(unitID)        pos[2] = pos[2] + h*0.75                for i = 1, 3 do  --set up the rectangle coordinates          rect[1][i] = pos[i] + cam.up[i]*12 - cam.right[i]* 0          rect[2][i] = pos[i] + cam.up[i]*12 + cam.right[i]*12          rect[3][i] = pos[i] - cam.up[i]* 0 + cam.right[i]*12           rect[4][i] = pos[i] - cam.up[i]* 0 - cam.right[i]* 0        end        gl.ResetState()                    gl.DepthTest(true)        gl.Texture("LuaUI/Images/ranks/"..rank..".tga")                        gl.MatrixMode(GL.TEXTURE)        gl.PushMatrix()        gl.Rotate(90, 1, 0, 0)        gl.PopMatrix()                gl.MatrixMode(GL.MODELVIEW)        gl.PushMatrix()        gl.Translate(-15*cam.right[1], -15*cam.right[2], -15*cam.right[3])        gl.PopMatrix()                gl.BeginEnd(GL.QUADS, function()              for i = 1, 4 do -- draw rectangle                  gl.Vertex(rect[i][1], rect[i][2], rect[i][3])                  gl.TexCoord(tex[i][1], tex[i][2])              end            end          )        gl.ResetState()      end    end  endend