You can have multiple *defs in one file.
I guess some knew that but I have never seen it anywhere except sometimes for cegs.
So why give a ohlala?
Imagine all the units in your mod are almost the same.
Or more realisticaly, you have alot of features that are really similiar:
if there are 10 different trees, then their featureDef is probally almost the same, except for the 3d model and name.
Fact: Most trees are 99% identical.
This is also true for rocks and buildings. and e&e units trololo
Normally you would have 10 files like
tree1.lua, tree2.lua, tree2.lua ... tree10.lua
And to change something (ie increase the footprint of all trees) you go through all 10 files by hand. Or use some batch editor.
But why not put all the similiar things in one file!
For example these signs:
are made by this file:
http://pastebin.com/rjCEBfrt
At the top of the file there is the featureDef= which defines all the stuff that all 5 features have in common, like same footprint, reclaim stuff etc.
Notice name, description, object are commentated out because those will be different.
Then in the next lines some empty tables are declared and the for-loop fills those with the "base" featureDef thing.
Now all all those features are still the same which is changed in the next step where it goes like
tpsign_1.name = "tpsign_1"
tpsign_1.object = "tpsign_1.s3o"
tpsign_1.description ="woof woof"
...
And in the end all the new tables are returned so Spring can read them.
Of course could be taken further, ie one could do
for i=1,5 do
signs.object = "sign_" .. i .. ".s3o"
...
blabla.
Pay attention to all the , } etc, if something is wrong Spring will not give any message at all but just ignore the file. Also Echo does not work it seems.
Multiple unit/feature/weapon defs per file
Moderator: Moderators
Re: Multiple unit/feature/weapon defs per file
Does this mean i could basically have for example Stumpy and Instigator in one file and they behave exactly like they were in 2 file originaly?
Re: Multiple unit/feature/weapon defs per file
To be honest I only tested with the the sign features so far.
But I do not see why it would not work with units etc too.
So I think yes.
But I do not see why it would not work with units etc too.
So I think yes.
Re: Multiple unit/feature/weapon defs per file
That should be Engine implented to be honest
This way Spring 1944 teams could box all those ausf├╝hrungs tanks
bashing in one file
Reducing clutter
Does this work for weapons as well?
nevermind redundant question.
This way Spring 1944 teams could box all those ausf├╝hrungs tanks
bashing in one file
Reducing clutter
nevermind redundant question.
Last edited by Karl on 02 Oct 2011, 13:17, edited 1 time in total.
Re: Multiple unit/feature/weapon defs per file
well, it is engine implented otherwise this would not work?That should be Engine implented to be honest
id think so.Does this work for weapons as well?
I will test with units later by combining all the civilian vehicles into one file.
redvan, bluevan, whitevan, yellowbus -> civvehicle.lua
Re: Multiple unit/feature/weapon defs per file
Well i don't know about it because it seems to be a SVN feature? I don't really check the svn version of Spring
Re: Multiple unit/feature/weapon defs per file
This is with current release.
Re: Multiple unit/feature/weapon defs per file
I must be sleeping under rocks how the hell i dint know that for 9+ Months about that?
Re: Multiple unit/feature/weapon defs per file
Multiple defs per file have always worked (they worked in TA! At least for weapons and features).
But OO style defs is something I've been planning for ages, and working on for the past few months;
Rifles - Has weapons inheriting from each other (see RUSMosinNagant and RUSPartisanMosinNagant)
Howitzers - has multiple inheritance (See how a howitzer weapon inherits from the howitzer base class, and then also either smoke or HE shell. The additional 'true' param concatenates the names together)
How it works:
http://spring1944.svn.sourceforge.net/v ... iew=markup
Also Echo works fine.
But OO style defs is something I've been planning for ages, and working on for the past few months;
Rifles - Has weapons inheriting from each other (see RUSMosinNagant and RUSPartisanMosinNagant)
Howitzers - has multiple inheritance (See how a howitzer weapon inherits from the howitzer base class, and then also either smoke or HE shell. The additional 'true' param concatenates the names together)
How it works:
http://spring1944.svn.sourceforge.net/v ... iew=markup
Also Echo works fine.
Re: Multiple unit/feature/weapon defs per file
Kernel Panic hero units are created by code (with most of tags copied from spam units).