More LUA problems (One more question)
Posted: Sat Jan 09, 2010 9:09 pm
by (Anonymous)
My problem has to do with ambushers. The same problem was addressed in the tutorial topic bu that solution didn't work for me. The map loads completly than crashes, no team select.
PS> If you notice any other errors please let me know
Offtopic: [small victory]100 posts, woot![/small victory]
Only relevant error message:
And LUA (green = ambush objective stuff:
PS> If you notice any other errors please let me know
Offtopic: [small victory]100 posts, woot![/small victory]
Only relevant error message:
Hidden/Spoiler:
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `SetTeamName' (number expected, got nil)
stack traceback:
[C]: in function `SetTeamName'
(none): in function `SetupTeams'
(none): in function `ScriptInit'
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `SetTeamName' (number expected, got nil)
stack traceback:
[C]: in function `SetTeamName'
(none): in function `SetupTeams'
(none): in function `ScriptInit'
Hidden/Spoiler:
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_SetGameRules("campaign")
ScriptCB_DoFile("Ambush")
-- Empire Attacking (attacker is always #1)
local ALL = 2
local IMP = 1
-- These variables do not change
local ATT = 1
local DEF = 2
AmbushTeam = 3
REB = RebelAmbush
function ScriptPostLoad()
ScriptCB_SetGameRules("campaign")
SetAIDifficulty(0, 0, "hard")
DisableAIAutoBalance()
--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}
cp3 = CommandPost:New{name = "cp3"}
cp4 = CommandPost:New{name = "cp4"}
--This sets up the actual objective. This needs to happen after cp's are defined
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
objectives_timer = CreateTimer("objectives_timer")
SetTimerValue(objectives_timer, 2)
StartTimer(objectives_timer)
begin_objectives = OnTimerElapse(
function(timer)
StartObjectives ()
ScriptCB_EnableCommandPostVO(0)
end,
objectives_timer
)
end
end
)
--objective 1; Find the other gunship
Objective1 = ObjectiveGoto:New{TeamATT = ATT,
text = "level.ITI.objectives.1", popupText = "level.ITI.objectives.1",
regionName = "gunship", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}
Objective1.OnStart = function(self)
att_obj1_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
MapAddEntityMarker("goto", "hud_objective_icon", 3.0, 1, "YELLOW", true)
end
Objective1.OnComplete = function(self)
DeleteAIGoal(att_obj1_aigoal)
ShowMessageText("game.objectives.complete")
ShowPopup("level.ITI.objectives.complete", ATT)
MapRemoveEntityMarker("goto")
end
--Objective 2; Kill the rebels
Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.ITI.objectives.2", popupText = "level.ITI.objectives.2"}
Dclass = TargetType:New{classname = "all_inf_rifleman", killLimit = 8}
Objective2:AddTarget(Dclass)
Objective2.OnStart = function(self)
att_obj1_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
SetupAmbushTrigger("rebels", "rebels", 8, 3)
end
Objective2.OnComplete = function(self)
DeleteAIGoal(att_obj1_aigoal)
ShowMessageText("game.objectives.complete")
ShowPopup("level.ITI.objectives.complete", ATT)
end
--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:Start()
EnableSPHeroRules()
end
function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4.0 }
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:Start()
end
---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------
function ScriptInit()
ReadDataFile("ingame.lvl")
SetMaxFlyHeight(40)
SetMaxPlayerFlyHeight(40)
SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo
ReadDataFile("sound\\tat.lvl;tat2gcw")
ReadDataFile("SIDE\\all.lvl",
"all_inf_rifleman",
"all_inf_rocketeer",
"all_inf_sniper",
"all_inf_engineer",
"all_inf_officer",
"all_inf_wookiee",
"all_hero_hansolo_tat")
ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_inf_officer",
"imp_inf_dark_trooper",
"imp_hero_bobafett",
"imp_fly_destroyer_dome" )
ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_tat_barge",
"tur_bldg_laser")
SetupTeams{
all = {
team = ALL,
units = 20,
reinforcements = 150,
soldier = { "all_inf_rifleman",9, 25},
assault = { "all_inf_rocketeer",1,4},
engineer = { "all_inf_engineer",1,4},
sniper = { "all_inf_sniper",1,4},
officer = { "all_inf_officer",1,4},
special = { "all_inf_wookiee",1,4},
},
imp = {
team = IMP,
units = 20,
reinforcements = 150,
soldier = { "imp_inf_rifleman",9, 25},
assault = { "imp_inf_rocketeer",1,4},
engineer = { "imp_inf_engineer",1,4},
sniper = { "imp_inf_sniper",1,4},
officer = { "imp_inf_officer",1,4},
special = { "imp_inf_dark_trooper",1,4},
},
reb = {
team = REB,
units = 8,
reinforcements = -1,
soldier = { "all_inf_rifleman",8, 8},
}
}
SetTeamAsEnemy(REB, IMP)
SetTeamAsEnemy(IMP, REB)
ClearAIGoals(REB)
AddAIGoal(REB, "Deathmatch", 100)
SetTeamName(REB, ALL)
SetHeroClass(ALL, "all_hero_hansolo_tat")
SetHeroClass(IMP, "imp_hero_bobafett")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_SetGameRules("campaign")
ScriptCB_DoFile("Ambush")
-- Empire Attacking (attacker is always #1)
local ALL = 2
local IMP = 1
-- These variables do not change
local ATT = 1
local DEF = 2
AmbushTeam = 3
REB = RebelAmbush
function ScriptPostLoad()
ScriptCB_SetGameRules("campaign")
SetAIDifficulty(0, 0, "hard")
DisableAIAutoBalance()
--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}
cp3 = CommandPost:New{name = "cp3"}
cp4 = CommandPost:New{name = "cp4"}
--This sets up the actual objective. This needs to happen after cp's are defined
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
objectives_timer = CreateTimer("objectives_timer")
SetTimerValue(objectives_timer, 2)
StartTimer(objectives_timer)
begin_objectives = OnTimerElapse(
function(timer)
StartObjectives ()
ScriptCB_EnableCommandPostVO(0)
end,
objectives_timer
)
end
end
)
--objective 1; Find the other gunship
Objective1 = ObjectiveGoto:New{TeamATT = ATT,
text = "level.ITI.objectives.1", popupText = "level.ITI.objectives.1",
regionName = "gunship", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}
Objective1.OnStart = function(self)
att_obj1_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
MapAddEntityMarker("goto", "hud_objective_icon", 3.0, 1, "YELLOW", true)
end
Objective1.OnComplete = function(self)
DeleteAIGoal(att_obj1_aigoal)
ShowMessageText("game.objectives.complete")
ShowPopup("level.ITI.objectives.complete", ATT)
MapRemoveEntityMarker("goto")
end
--Objective 2; Kill the rebels
Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.ITI.objectives.2", popupText = "level.ITI.objectives.2"}
Dclass = TargetType:New{classname = "all_inf_rifleman", killLimit = 8}
Objective2:AddTarget(Dclass)
Objective2.OnStart = function(self)
att_obj1_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
SetupAmbushTrigger("rebels", "rebels", 8, 3)
end
Objective2.OnComplete = function(self)
DeleteAIGoal(att_obj1_aigoal)
ShowMessageText("game.objectives.complete")
ShowPopup("level.ITI.objectives.complete", ATT)
end
--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:Start()
EnableSPHeroRules()
end
function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4.0 }
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:Start()
end
---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------
function ScriptInit()
ReadDataFile("ingame.lvl")
SetMaxFlyHeight(40)
SetMaxPlayerFlyHeight(40)
SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo
ReadDataFile("sound\\tat.lvl;tat2gcw")
ReadDataFile("SIDE\\all.lvl",
"all_inf_rifleman",
"all_inf_rocketeer",
"all_inf_sniper",
"all_inf_engineer",
"all_inf_officer",
"all_inf_wookiee",
"all_hero_hansolo_tat")
ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_inf_officer",
"imp_inf_dark_trooper",
"imp_hero_bobafett",
"imp_fly_destroyer_dome" )
ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_tat_barge",
"tur_bldg_laser")
SetupTeams{
all = {
team = ALL,
units = 20,
reinforcements = 150,
soldier = { "all_inf_rifleman",9, 25},
assault = { "all_inf_rocketeer",1,4},
engineer = { "all_inf_engineer",1,4},
sniper = { "all_inf_sniper",1,4},
officer = { "all_inf_officer",1,4},
special = { "all_inf_wookiee",1,4},
},
imp = {
team = IMP,
units = 20,
reinforcements = 150,
soldier = { "imp_inf_rifleman",9, 25},
assault = { "imp_inf_rocketeer",1,4},
engineer = { "imp_inf_engineer",1,4},
sniper = { "imp_inf_sniper",1,4},
officer = { "imp_inf_officer",1,4},
special = { "imp_inf_dark_trooper",1,4},
},
reb = {
team = REB,
units = 8,
reinforcements = -1,
soldier = { "all_inf_rifleman",8, 8},
}
}
SetTeamAsEnemy(REB, IMP)
SetTeamAsEnemy(IMP, REB)
ClearAIGoals(REB)
AddAIGoal(REB, "Deathmatch", 100)
SetTeamName(REB, ALL)
SetHeroClass(ALL, "all_hero_hansolo_tat")
SetHeroClass(IMP, "imp_hero_bobafett")