[Request] Range widget

[Request] Range widget

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Hobo Joe
Posts: 1001
Joined: 02 Jan 2008, 21:55

[Request] Range widget

Post by Hobo Joe »

Is there a widget that shows the range of all allied and enemy units at all times? Possibly in different colors? :D


If not, how difficult would it be to make something like this? (I know nothing about lua)
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Re: [Request] Range widget

Post by Neddie »

There is one that shows the range of defenses which is bundled in a few of the *A modifications. I believe there is another for all units, but it may have just been a proof of concept.
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: [Request] Range widget

Post by Jazcash »

Defense Range by VBS?
User avatar
Hobo Joe
Posts: 1001
Joined: 02 Jan 2008, 21:55

Re: [Request] Range widget

Post by Hobo Joe »

Neddie wrote:There is one that shows the range of defenses which is bundled in a few of the *A modifications. I believe there is another for all units, but it may have just been a proof of concept.
Yeah, I have that one. I'm just thinking something that will make microing outside of range of mobile units a little more convenient, without holding shift and mousing over the enemy constantly.
luckywaldo7
Posts: 1398
Joined: 17 Sep 2008, 04:36

Re: [Request] Range widget

Post by luckywaldo7 »

Try this?
User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

Re: [Request] Range widget

Post by manolo_ »

also at SD
User avatar
Hobo Joe
Posts: 1001
Joined: 02 Jan 2008, 21:55

Re: [Request] Range widget

Post by Hobo Joe »

Thanks, that's at least part of what I was looking for
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: [Request] Range widget

Post by AF »

Here's a basic one for radar and jammer range:

Code: Select all

function widget:GetInfo()
  return {
    name      = "Radar Ranges",
    desc      = "Draws radar ranges on the map when radar units are selected.",
    author    = "AF",
    date      = "28/07/2007",
    license   = "GNU GPL, v2 or later",
    layer     = 5,
    enabled   = true  --  loaded by default?
  }
end

function widget:DrawWorldPreUnit()
  local units = Spring.GetSelectedUnits()
  gl.LineWidth(5)
  for _,uid in ipairs(Spring.GetSelectedUnits()) do
--  for _,uid in pairs(units) do
	local udid = Spring.GetUnitDefID(uid)
    local ud = udid and UnitDefs[udid] or nil
    if (ud and (ud.radarRadius > 400)) then
	  gl.Color(0.5, 0.5, 1, 0.5)
	  local x, y, z = Spring.GetUnitBasePosition(uid)
      if (x) then
        gl.DrawGroundCircle(x, y, z, ud.radarRadius, 128)
      end
	end
	if (ud and (ud.jammerRadius > 200)) then
	  gl.Color(1, 0, 0, 0.5)
	  local x, y, z = Spring.GetUnitBasePosition(uid)
      if (x) then
        gl.DrawGroundCircle(x, y, z, ud.jammerRadius, 128)
      end
	end
  end
  gl.LineWidth(1)
end
User avatar
Hobo Joe
Posts: 1001
Joined: 02 Jan 2008, 21:55

Re: [Request] Range widget

Post by Hobo Joe »

AF wrote:Here's a basic one for radar and jammer range:

Code: Select all

function widget:GetInfo()
  return {
    name      = "Radar Ranges",
    desc      = "Draws radar ranges on the map when radar units are selected.",
    author    = "AF",
    date      = "28/07/2007",
    license   = "GNU GPL, v2 or later",
    layer     = 5,
    enabled   = true  --  loaded by default?
  }
end

function widget:DrawWorldPreUnit()
  local units = Spring.GetSelectedUnits()
  gl.LineWidth(5)
  for _,uid in ipairs(Spring.GetSelectedUnits()) do
--  for _,uid in pairs(units) do
	local udid = Spring.GetUnitDefID(uid)
    local ud = udid and UnitDefs[udid] or nil
    if (ud and (ud.radarRadius > 400)) then
	  gl.Color(0.5, 0.5, 1, 0.5)
	  local x, y, z = Spring.GetUnitBasePosition(uid)
      if (x) then
        gl.DrawGroundCircle(x, y, z, ud.radarRadius, 128)
      end
	end
	if (ud and (ud.jammerRadius > 200)) then
	  gl.Color(1, 0, 0, 0.5)
	  local x, y, z = Spring.GetUnitBasePosition(uid)
      if (x) then
        gl.DrawGroundCircle(x, y, z, ud.jammerRadius, 128)
      end
	end
  end
  gl.LineWidth(1)
end

I usually play with the radar overlay on, except late game when it lowers my fps too much, so I don't really need this. Thanks anyway though. Maybe I should learn lua...
Post Reply

Return to “Lua Scripts”