------------------------------------------------------------------------------------ function widget:GetInfo() return { name = "DT", desc = "Marks lines to show DT", author = "Niobium", date = "4 January 2009", license = "GNU GPL, v2 or later", layer = 0, enabled = true -- loaded by default? } end ------------------------------------------------------------------------------------ local spGetAllFeatures = Spring.GetAllFeatures local spGetFeaturePosition = Spring.GetFeaturePosition local spGetFeatureDefID = Spring.GetFeatureDefID local spGetMyAllyTeamID = Spring.GetMyAllyTeamID local spGetFeatureAllyTeam = Spring.GetFeatureAllyTeam local spMarkerAddLine = Spring.MarkerAddLine local spGetMyPlayerID = Spring.GetMyPlayerID local spGetPlayerInfo = Spring.GetPlayerInfo local spEcho = Spring.Echo ------------------------------------------------------------------------------------ function ALine(x1, y1, x2, y2) return { x1 = x1, y1 = y1, x2 = x2, y2 = y2 } end local r = 10 -- DT size = 32 x 32 --[[ local DTLines = { ALine(-r, -r, r, -r), ALine( r, -r, r, r), ALine( r, r, -r, r), ALine(-r, r, -r, -r), } --]] local DTLines = { ALine(-r, -r, r, r), ALine( r, -r, -r, r), } local DTDrawn = {} local DTSet = {} local DTArray = { "dragonsteeth", "dragonsteeth_core", "fortification", "fortification_core", "floatingteeth", "floatingteeth_core", } ------------------------------------------------------------------------------------ function widget:Initialize() for i, v in pairs(DTArray) do DTSet[v] = true end end local lastUpdate = 0 function widget:Update(deltaTime) lastUpdate = lastUpdate + deltaTime if (lastUpdate < 0.5) then return end lastUpdate = 0 local _, _, spec = spGetPlayerInfo(spGetMyPlayerID()) if (spec == true) then spEcho("
Spectator mode. Widget removed.") widgetHandler:RemoveWidget() return false end local features = spGetAllFeatures() for _, fID in ipairs(features) do if (DTDrawn[fID] == nil) then local fName = FeatureDefs[spGetFeatureDefID(fID)].name if (DTSet[fName]) then local myAllyID = spGetMyAllyTeamID() local fAllyID = spGetFeatureAllyTeam(fID) if (myAllyID ~= fAllyID) then local x, y, z = spGetFeaturePosition(fID) for _, p in ipairs(DTLines) do spMarkerAddLine((x + p.x1), y, (z + p.y1), (x + p.x2), y, (z + p.y2)) end DTDrawn[fID] = true end end end end end