Page 1 of 1
Lua startscript question
Posted: 21 Oct 2007, 21:07
by aash29
Wasn't able to figure it out on my own.
I want to spawn kbot lab instead of commander when game starts.
Code: Select all
function barrackScript:SetupRegular()
local p = TdfParser()
p:LoadFile("gamedata\\sidedata.tdf")
local s0 = p:GetString("armcom", "side0\\commander");
local s1 = p:GetString("corcom", "side1\\commander");
p = TdfParser()
p:LoadFile(map.GetTDFName())
local x0, z0, x1, z1
x0 = p:GetFloat(1000, "MAP\\TEAM0\\StartPosX")
z0 = p:GetFloat(1000, "MAP\\TEAM0\\StartPosZ")
x1 = p:GetFloat(1200, "MAP\\TEAM1\\StartPosX")
z1 = p:GetFloat(1200, "MAP\\TEAM1\\StartPosZ")
units.Load(s0, float3(x0, 80, z0), 0, false)
units.Load(s1, float3(x1, 80, z1), 1, false)
end
I suppose
Code: Select all
local s0 = p:GetString("armcom", "side0\\commander");
local s1 = p:GetString("corcom", "side1\\commander");
has to be modified, but how?
Thanks in advance.
Posted: 21 Oct 2007, 22:55
by Gnomre
Make your own mod/mutator with gamedata/sidedata.tdf. Open sidedata.tdf in notepad and... well, it should become pretty clear pretty quickly.
Posted: 21 Oct 2007, 23:00
by Snipawolf
lol, doing this with lua? I believe you should learn a mods ins and outs before making scripts for one?
Posted: 22 Oct 2007, 17:07
by aash29
thanks Gnome,
Snipawolf
well, most noobs are advised to reverse-engineer and hack other mods,
I thought spawning units at start was a basic thing - was I wrong?
Posted: 22 Oct 2007, 18:13
by Torrasque
Have you even try to to open sidedata.tdf before complaining ?
Have you read the
wiki ?
Pehaps you should accept that you can't mod without making a little efforts...
Knowing the basis of the programation would help too.
edit:
I've look at your problem.
The two line you've got certainly give you the real name of the unit. ( in this case : ARMCOM and CORCOM.
Those string are now in s0 and s1. and you can see a little down that s0 and s1 are used in a load unit function. So remplacing s0 and s1 with CORLAB or ARMLAB could work.
You can found name of the unit in sidedata.tdf, or in this site :
http://modinfo.adune.nl/
Posted: 22 Oct 2007, 18:34
by aash29
By no means I'm complaining,
and thanks all of you for response
So I can do without p:GetString at all?
Posted: 22 Oct 2007, 21:58
by Torrasque
oh, sorry, I misinterpreted you.
If it was regular units, I would say yes. But as it is commanders, I don't know if there is something special with them.
The best way to know is to try

Posted: 22 Oct 2007, 22:38
by Gnomre
There are some various FBI tags to make them behave more like (OTA) commanders, for example:
commander=1; //makes it work with Commander Death: Ends and I think the ctrl+c shortcut (can be used on mass produced units, I believe, which in a way 'disables' both of these features)
hidedamage=1; //hides the healthbar and resource income from enemies (can be used on any unit)
showplayername=1; //shows the owner's name instead of the name of the unit (can be used on any unit)
decoyfor=armcom; //used by decoy commanders. It actually shouldn't be limited to usage with commanders
Those are the ones that are mostly used in conjunction with commanders. Other stuff (cloaking, resource production, etc) is more general.
Commanders can be factories without a problem, but it might not be too great if played on a map with poorly positioned start points (near the map edge or on the side of a hill or something) or with users choosing start points in game at these positions. Plus, commanders this way might end up on top of metal patches, and commanders cannot be metal extractors and at the same time have the ability to build without lua to spawn fake metal extractors.
Other than those concerns you must pay attention to, commanders can be anything.
Posted: 23 Oct 2007, 18:51
by aash29
great,
thanks again for complete answer