.give all mobile

.give all mobile

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

.give all mobile

Post by Caydr »

Can we have an extension to the .give all command? What I'd like it to do is give all the units with a movement speed which is greater than 0.

Thanks
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

You could setup a LuaUI call that generated
a ".give" command for all mobile units. The
problem would be spacing them (although
that is possible too)
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Spacing isn't really a problem, they're mobile :)

Here's the code ... just stick it in gui.lua and type
the following into the console: /luaui givemobile

P.S You'll want to start with a gui.lua that is already
known to work. LuaUI requires a valid LayoutButtons()
function to work (it is the only required call-in).

Code: Select all

function ConfigureLayout(command)
  if (command == "givemobile") then
    GiveMobile()
  end
end

Code: Select all

function GiveMobile()
  Spring.SendCommands({"say .cheat 1"}) -- enable cheating
  for udid,ud in pairs(UnitDefs) do
    if (ud and ud.canMove and (ud.speed > 0)) then
      Spring.SendCommands({"say .give " .. ud.name}) 
    end
  end  
end
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Note that it's fairly easy to make little adjustments to this code
(especially when you can use /luaui reload to "recompile" it on
the fly, I've got "luaui reload" bound to Meta+r). One thing that
I did notice is that you may want yet another level of control with
respect to water based units. Checking against ud.minWaterDepth
should do the trick.
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Post by Caydr »

That's very interesting, I'll give that a shot. It'll save me the time of nagging you about the ".give water" and ".give air" commands too :P
Post Reply

Return to “Feature Requests”