Widget that show how many units left to MAX-Unit...

Widget that show how many units left to MAX-Unit...

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

Moderator: Moderators

Post Reply
R-TEAM
Posts: 177
Joined: 22 Jan 2009, 19:25

Widget that show how many units left to MAX-Unit...

Post by R-TEAM »

Hi,

if i play in LAN with my little bit old second-PC i set the max units
variable low enough to deal with the cpu power he have ... ;)

But found it is a bit frustrating if you build a large army and then -
nothing more - stop - no go .... have reached the max ... :(

It would be nice show a widget the units left (or the actual number)
to planing this better ...

Like ->
I have set max 500 Units - if i have 450 the widget show a message:
"Only 50 units left !" ...
By a max of 1000 units the border should hit at 100 left...
(if the number bigger - the number of fabrics that build units is bigger too imho - so the amount of planed/in production units is higher)

Regards
R-TEAM
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Widget that show how many units left to MAX-Unit...

Post by hoijui »

Ctrl-A
User avatar
manolo_
Posts: 1370
Joined: 01 Jul 2008, 00:08

Re: Widget that show how many units left to MAX-Unit...

Post by manolo_ »

nice widget hoijui^^
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: Widget that show how many units left to MAX-Unit...

Post by Pendrokar »

hoijui wrote:Ctrl-A
What if you forgot how many there could still be?
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Re: Widget that show how many units left to MAX-Unit...

Post by MelTraX »

Alt-Tab
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Widget that show how many units left to MAX-Unit...

Post by KDR_11k »

ctrl-shift-escape
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Re: Widget that show how many units left to MAX-Unit...

Post by MelTraX »

OK, I feel bad for giving you a stupid answer:

Code: Select all

function widget:GetInfo()
  return {
    name    = "Max Units Warning",
    desc    = "Outputs a warning in the console if you use 90% of the max units.",
    author  = "MelTraX",
    date    = "2009-09-16",
    license = "Public Domain",
    layer   = 1,
    enabled = false
  }
end

function widget:UnitCreated()
  local max = Spring.GetModOptions()['maxunits'] or 500
  local current = #Spring.GetTeamUnits(Spring.GetMyTeamID())
  if max * 0.9 == current then
    Spring.Echo(string.format('You have %d units. The maximum unit count is set to %d.', current, max))
  end
end
Yes, it's not pretty but it's better than nothing.
R-TEAM
Posts: 177
Joined: 22 Jan 2009, 19:25

Re: Widget that show how many units left to MAX-Unit...

Post by R-TEAM »

Hi,

Thanks MelTraX ;)

And Thanks hoijui, but if you have a slow cpu and many,many Units and hit ctrl-alt .........
;)

Regards
R-TEAM
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Widget that show how many units left to MAX-Unit...

Post by lurker »

doesn't tell you max units?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Widget that show how many units left to MAX-Unit...

Post by hoijui »

i have s slow CPU too.. but as i dont check num-units every few secs, it is ok.
The problem with Ctrl-Alt is rather, that you have to be very carefull to not accidentialy issue an order :D
happend to me once; big @#%@$%@#$ moment!
Post Reply

Return to “Lua Scripts”