`AddUnitClass' (number expected, got nil)

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
Caleb1117
2008 Most Original Avatar
Posts: 3096
Joined: Sun Aug 20, 2006 5:55 pm
Projects :: No Mod project currently.
xbox live or psn: No gamertag set
Location: X-Fire: caleb1117 ಠ_ಠ

`AddUnitClass' (number expected, got nil)

Post 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
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

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

Post by Teancum »

That's really odd. Try changing all to ALL. But that's me picking at straws.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

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

Post by Maveritchell »

Actually, I'm pretty sure Tean's right. Variables are usually case-sensitive.
Caleb1117
2008 Most Original Avatar
Posts: 3096
Joined: Sun Aug 20, 2006 5:55 pm
Projects :: No Mod project currently.
xbox live or psn: No gamertag set
Location: X-Fire: caleb1117 ಠ_ಠ

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

Post 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:
t551
General
General
Posts: 791
Joined: Sat Jul 16, 2005 3:23 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

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

Post 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.
Post Reply