Joined: 22 Feb 2006, 01:02 Location: cheap kitchen
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!
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[i].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 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)
Users browsing this forum: No registered users and 0 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum