Lua startscript question

Lua startscript question

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

Moderator: Moderators

Post Reply
aash29
Posts: 15
Joined: 23 Sep 2007, 20:28

Lua startscript question

Post 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.
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post 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.
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

lol, doing this with lua? I believe you should learn a mods ins and outs before making scripts for one?
aash29
Posts: 15
Joined: 23 Sep 2007, 20:28

Post 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?
Torrasque
Posts: 1022
Joined: 05 Oct 2004, 23:55

Post 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/
aash29
Posts: 15
Joined: 23 Sep 2007, 20:28

Post by aash29 »

By no means I'm complaining,
and thanks all of you for response
So I can do without p:GetString at all?
Torrasque
Posts: 1022
Joined: 05 Oct 2004, 23:55

Post 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 ;)
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post 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.
aash29
Posts: 15
Joined: 23 Sep 2007, 20:28

Post by aash29 »

great,
thanks again for complete answer
Post Reply

Return to “Lua Scripts”