Request: auto hold position for long range units.
Moderator: Moderators
Request: auto hold position for long range units.
hi guys, i was wondering if someone could make a lua script that would turn long range units(like merls, mobile artillery the core missile tank, missile ship etc) hold position, i like to use them for defense or park them next to some place and let them shell.
i would write it myself, but iam a newb when it comes to lua, and theres no way for me to figure out whats wrong with it as theres no error messages, it just doesnt appear in the menu when it doesnt work.
thanks
i would write it myself, but iam a newb when it comes to lua, and theres no way for me to figure out whats wrong with it as theres no error messages, it just doesnt appear in the menu when it doesnt work.
thanks
Section 5.3 in http://www.lua.org/manual/5.0/manual.html
P.S. I don't really think that filtering by name is the best way
to go. See if you can pick out what you need from the UnitDefs
and WeaponDefs structures (their parameters are listed at the
end of LuaUI/API.txt).
P.S. I don't really think that filtering by name is the best way
to go. See if you can pick out what you need from the UnitDefs
and WeaponDefs structures (their parameters are listed at the
end of LuaUI/API.txt).
what i want is only long ranged units to be hold position, my script works, i just wanted to add a way to put different ranges for different mods, but i know nothing of lua so i dont know how to see if a entry with a certain key exists in a table acting as a associative array(std::map in c++, dictionary in python).
Having to set EVERY one of my factories every single game is pretty time consuming. :X And hard to remember.ZellSF wrote:Eh, if you want to do it for everything, just set your factories to it, that's not difficult, or time consuming.LOrDo wrote:Scratch long range units. Make it do that for EVERYTHING. I hate my units suddenly attack a nearby somthing only to get blown up by a dozen HLT's.
Automation is win.
Code: Select all
local val = table[key]
if (val ~= nil) then
<key, val> was in table
else
<key, val> was not in table
end
and how do you format strings in lua.
in python it would be
blah = "hello my name is %s iam %d years old"%(name,age)
in c++ it would be.
sprintf(blah,"hello my name is %s iam %d years old",name,age);
and for some reason(i cant exactly get error messages so i have no idea why)
this makes the script not load.
in python it would be
blah = "hello my name is %s iam %d years old"%(name,age)
in c++ it would be.
sprintf(blah,"hello my name is %s iam %d years old",name,age);
and for some reason(i cant exactly get error messages so i have no idea why)
this makes the script not load.
Code: Select all
local Ranges = {
["AASS223.sdz"] = 300,
}
local RangeGreaterThen = nil
---pick the range from the array.
RangeGreaterThen = Ranges[Game.modName]
if(RangeGreaterThen ~= nil)
Spring.SendCommands({"echo dingdong"})
else
RangeGreaterThen = 300
Spring.SendCommands({"echo Loaded"})
Section 5.3 (string.format)
http://www.lua.org/manual/5.0/manual.html
You can also use the ".." concatenation operator and the
tostring() function (numbers will automatically be converted
to strings when using "..").
example:
http://www.lua.org/manual/5.0/manual.html
You can also use the ".." concatenation operator and the
tostring() function (numbers will automatically be converted
to strings when using "..").
example:
Code: Select all
value = 12
print("value = " .. value)