Page 1 of 1
Help with weapondefs_post
Posted: 09 Apr 2013, 01:59
by Forboding Angel
I want to do this:
Code: Select all
for id,wd in pairs(WeaponDefs) do
wd.energycost = wd.damage.default * 0.05
end
Essentially, I want to take each weapon's total default damage, then divide that by 20, and whatever number that is, make it the energypershot value.
I'm doing something wrong. Can someone halp?
Re: Help with weapondefs_post
Posted: 09 Apr 2013, 02:24
by knorke
divide by 20 is not same as multipy with 0.2
Re: Help with weapondefs_post
Posted: 09 Apr 2013, 02:27
by Forboding Angel
My apologies. * 0.05 fixed
Re: Help with weapondefs_post
Posted: 09 Apr 2013, 02:53
by Forboding Angel
Update, I did Spring.Echo(wd.name) and it output the names of only the weapons in the weapons folder and apparently skipped the weapons housed in unitdefs.
Tried putting this:
Code: Select all
for id,wd in pairs(WeaponDefs) do
wd.energycost = wd.damage.default * 0.05
Spring.Echo(wd.name)
Spring.Echo(wd.energycost)
end
In unitdefs_post, but keep getting this error:
Code: Select all
Error: Spring: Incorrect/Missing content: Error in main(): Defs-Parser: [string "gamedata/defs.lua"]:38: [string "gamedata/defs.lua"]:26: error = 2, gamedata/unitDefs.lua, error = 2, gamedata/unitdefs_post.lua, [string "gamedata/unitdefs_post.lua"]:45: bad argument #1 to 'pairs' (table expected, got nil)
Re: Help with weapondefs_post
Posted: 09 Apr 2013, 09:11
by Forboding Angel
I figured it out. Long story short there is a function in my weapondefs_post that converts unitdef weapondefs to be usable in weapondefs post. I needed to have my little blurb in that function. THe moment I put it there everything was fine.
Re: Help with weapondefs_post
Posted: 09 Apr 2013, 09:14
by Jools
for id,wd in pairs(WeaponDefs) do
That is line 45 in unitdefs_post? The error is that
WeaponDefs is nil. Is that maybe not accessible from unitdefs_post?