I want to take all my unit explosions and stick them in a single luadef, I do not want them inside the unit files. How do I go about doing this (as in, what would the file look like and would it go in weapons or in units folders?)?
edit: changed the thread title so that it should show up in searches for similar problems.
converting tdf to lua (luadefs) Weapon - Unit Explosions
Moderator: Moderators
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
converting tdf to lua (luadefs) Weapon - Unit Explosions
Last edited by Forboding Angel on 02 Nov 2009, 21:49, edited 1 time in total.
Re: Technically this is the wrong place (combining luadefs)
What do you mean by unit explosions? The weapons that detonate when the unit dies or the explosion FX?Forboding Angel wrote:I want to take all my unit explosions and stick them in a single luadef, I do not want them inside the unit files. How do I go about doing this (as in, what would the file look like and would it go in weapons or in units folders?)?
I'll presume the former considering what you said, in which case, weapons folder. I don't have an example to hand of a lua weapondef, but i imagine it is done much the same as a lua unit def. Someone was working on one recently, sorry I forget who it was, but it was for one of the new fantasy projects iirc.
Code: Select all
unitDeaths = {
smallDeath = {
name = "small death",
etc = "etc",
},
bigDeath = {
name = "big death",
andSoOn = "and so on",
},
}
return lowerkeys(unitDeaths)
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Technically this is the wrong place (combining luadefs)
Yes, preciselyFLOZi wrote:What do you mean by unit explosions?

Yes that syntax looks correct, but there are always headers and stuff at the tops and bottoms of the luadef files, and tbh I know that if I mess up the syntax, spring will outright crash on loading, so I'm wanting to avoid any obvious pitfalls if I can.
Anyone know what the header and footer of the file should look like?
Thanks FLOZi

Re: Technically this is the wrong place (combining luadefs)
Lua being what it is the syntax is very flexible, as long as it is valid lua, and as long as the code returns a table and the table contains the correct keys.
is as valid as:
That lowerkeys function is just a weird thing somebody (probably from CA) added to make the file a little more readable since it appears the engine wants lowercasekey="value" as table members but the person who wrote the def prefers camelCaseKey="value".
In short the file is actually a function, not a data structure.
Code: Select all
return {
key="value",
key2="value"
}
Code: Select all
foo = {}
foo['key'] = "value"
foo['key2'] = "value"
return foo
In short the file is actually a function, not a data structure.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Technically this is the wrong place (combining luadefs)
Thanks spliff, your last sentence basically answered my question and it works great 
btw this was the header I needed (answered by flozi above)
--------------------------------------------------------------------------------
unitDeaths = {
and the footer needed is this:
return lowerkeys(unitDeaths)
SO basically when it's all said and done, if you were to make weapons for the "weapons" folder in your mod in luadefs it would look sorta like this:

btw this was the header I needed (answered by flozi above)
--------------------------------------------------------------------------------
unitDeaths = {
and the footer needed is this:
return lowerkeys(unitDeaths)
SO basically when it's all said and done, if you were to make weapons for the "weapons" folder in your mod in luadefs it would look sorta like this:
--------------------------------------------------------------------------------
unitDeaths = {
SMALL_BUILDING = {
name = "Small building",
rendertype=4,
ballistic=1,
turret=1,
range=480,
reloadtime=3.6,
weaponvelocity=250,
areaofeffect=205,
soundstart="explode2.wav",
soundhit="explode2.wav",
explosiongenerator="custom:FACTORY_EXPLOSION_SMALL",
damage = {
default = 10,
},
},
}
return lowerkeys(unitDeaths)