Page 1 of 1

`AddUnitClass' (number expected, got nil)

Posted: Tue Nov 13, 2007 3:59 pm
by Caleb1117
Ok, my head is frazeld and I have no idea what is wrong, but elimination (assualt) crashes, I have narrowed it to one level 3 error, and it is:
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `AddUnitClass' (number expected, got nil)
stack traceback:
[C]: in function `AddUnitClass'
(none): in function `ScriptInit'
Now it quite obviously has to do with the AddUnitClass line in the lua, I had added one for bastila.
But it worked fine on the first test, and now this.

heres the signifigant part of the lua.

ReadDataFile("sound\\tat.lvl;tat2gcw")
ReadDataFile("SIDE\\rep.lvl",
"rep_hero_macewindu",
"rep_hero_aalya",
"rep_hero_kiyadimundi",
"rep_hero_obiwan")

ReadDataFile("dc:SIDE\\kor.lvl",
"kor_knight_02",
"kor_inf_yoda",
"kor_inf_wookie",
"kor_inf_Revan",
"kor_inf_mission",
"kor_inf_Malak",
"kor_hero_carthonasi",
"kor_hero_sithmask",
"kor_hero_uthar",
"kor_hero_yuthura",
"kor_knight_bast")

ReadDataFile("dc:SIDE\\orep.lvl",
"orep_knight_09",
"orep_knight_03")

ReadDataFile("dc:SIDE\\sith.lvl",
"sith_inf_Sithap")

ReadDataFile("SIDE\\all.lvl",
"all_hero_luke_jedi")

ReadDataFile("SIDE\\imp.lvl",
"imp_hero_darthvader")

ReadDataFile("dc:SIDE\\man.lvl",
"man_inf_mand1",
"man_inf_mand2",
"man_duros_noob",
"man_inf_mand3")

ReadDataFile("SIDE\\cis.lvl",
"cis_hero_countdooku")

--[[ Turrets disabled
ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_chaingun_roof",
"tur_weap_built_gunturret")
SetMemoryPoolSize("MountedTurret", 15)
--]]

--ReadDataFile("SIDE\\snw.lvl", "snw_inf_wampa")

SetupTeams{
hero = {
team = ALL,
units = 12,
reinforcements = -1,
soldier = { "kor_knight_02",1,2},
assault = { "orep_knight_09", 1,2},
engineer= { "orep_knight_03", 1,2},
sniper = { "kor_inf_yoda", 1,2},
officer = { "kor_inf_mission", 1,2},
special = { "kor_hero_carthonasi", 1,2},
},
}
AddUnitClass(all, "kor_knight_bast",1,2)

SetupTeams{
villain = {
team = IMP,
units = 12,
reinforcements = -1,
soldier = { "kor_inf_Revan", 1,2},
assault = { "kor_inf_Malak",1,2},
engineer= { "kor_inf_wookie", 1,2},
sniper = { "sith_inf_Sithap", 1,2},
officer = { "kor_hero_uthar", 1,2},
special = { "kor_hero_yuthura", 1,2},

},
}
AddUnitClass(IMP, "kor_hero_sithmask",1,2)
Bastila is the kor_knight_bast

Re: `AddUnitClass' (number expected, got nil)

Posted: Tue Nov 13, 2007 7:32 pm
by Teancum
That's really odd. Try changing all to ALL. But that's me picking at straws.

Re: `AddUnitClass' (number expected, got nil)

Posted: Tue Nov 13, 2007 8:11 pm
by Maveritchell
Actually, I'm pretty sure Tean's right. Variables are usually case-sensitive.

Re: `AddUnitClass' (number expected, got nil)

Posted: Tue Nov 13, 2007 8:49 pm
by Caleb1117
Yea, it was the lack of caps, Foolis helped me out over x-fire.
I had a nagging feeling that it would be something obvious.

:cpu:

Re: `AddUnitClass' (number expected, got nil)

Posted: Fri Nov 16, 2007 10:38 pm
by t551
For future reference, the error message wasn't really cryptic at all:

It gave you the line number, the function call, and even which argument was bad (#1).

It told you what was bad -- that it got a null type instead of what it was expecting.