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
.give all mobile
Moderator: Moderators
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).
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
endCode: 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
endNote 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.
(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.
