Page 1 of 1

Game doesn't like my lua? (Solved)

Posted: Mon Mar 09, 2009 11:07 am
by bobfinkl
This is my first lua error in a long time, and I don't have a clue how it is even possible. I was munging some work done on the map and a 4th objective (which I deleted trying to get rid of the error), and I get this in my error log.
Hidden/Spoiler:
C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\CHL\CHLg_eli.lua:341: `end' expected (to close `function' at line 20) near `<eof>'
ERROR[scriptmunge scripts\CHL\CHLg_eli.lua]:Could not read input file.ERROR[scriptmunge scripts\CHL\CHLg_eli.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings

ERROR[levelpack mission\CHLg_eli.req]:Expecting bracket, but none was found.
File : munged\pc\chlg_eli.script.req(1)...

ucft <--
ERROR[levelpack mission\CHLg_eli.req]:Expecting bracket, but none was found.
File : munged\pc\chlg_eli.script.req(1)...

ucft <--

2 Errors 0 Warnings
Here is my lua.
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_SetGameRules("Campaign")

-- Empire Attacking (attacker is always #1)
local ALL = 2
local IMP = 1
-- These variables do not change
local ATT = 1
local DEF = 2

function ScriptPostLoad()

SetAIDifficulty(0, 2, "hard")
SetAIDifficulty(0, 3, "hard")
SetAIDifficulty(0, 4, "hard")
ScriptCB_SetGameRules("campaign")
KillObject("eli_cp2")
KillObject("eli_cp3")
KillObject("eli_cp4")

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
)

--Go to convoy objective #1
Objective1 = ObjectiveGoto:New{TeamATT = ATT, -- objective made
text = "level.corellia.c.1", popupText = "level.corellia.c.pop.1", -- show objective on screen
regionName = "goto", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}
Objective1.OnStart = function(self)
MapAddEntityMarker("goto", "hud_objective_icon", 3.0, 1, "YELLOW", true) -- AI objective
Objective1.OnComplete = function(self)
ActivateRegion("loseregion1")
end
end

--Wait for commander to arrive
rebel_count = 1
Objective2 = Objective:New{TeamATT = ATT,
text = "level.corellia.c.2", popupText = "level.corellia.c.pop.2",
timeLimit = 70, timeLimitWinningTeam = ATT}
testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "loseregion1") then
SetReinforcementCount(ATT, 0)
end
end,
"loseregion1"
)

Objective2NoKill = OnObjectKill(
function(object, killer)
if killer and IsCharacterHuman(killer) and GetObjectTeam(object) == DEF and GetObjectLastHitWeaponClass(object) == "imp_weap_inf_sniper_rifle" then
rebel_count = rebel_count - 1
if rebel_count == 0 then
SetReinforcementCount(ATT, 0)
end
end
end
)

Objective2.OnStart = function(self)
AddAIGoal(DEF, "Conquest", 100000, "objective3_cp")
RespawnObject("eli_cp2")
Objective2.OnStart = function(self)
KillObject("eli_cp2")
end

--Kill the commander
Commander = TargetType:New{classname = "all_inf_rocketeer_jungle", killLimit = 1, iconScale = 0.0}
Objective3 = ObjectiveAssault:New{TeamATT = ATT,
text = "level.corellia.c.3", popupText = "level.corellia.c.pop.3",
timeLimit = 10, timeLimitWinningTeam = DEF}
Objective3:AddTarget(Commander)

Objective2NoKill = OnObjectKill(
function(object, killer)
if killer and IsCharacterHuman(killer) and GetObjectTeam(object) == DEF and GetObjectLastHitWeaponClass(object) == "imp_weap_inf_sniper_rifle" then
rebel_count = rebel_count - 1
if rebel_count == 0 then
SetReinforcementCount(ATT, 1)
end
end
end
)


testfunction = OnEnterRegion(
function(region, player)
if IsCharacterInRegion(player, "loseregion1") then
SetReinforcementCount(ATT, 0)
end
end,
"loseregion1"
)

Objective3.OnStart = function(self)
AddAIGoal(3, "Conquest", 100000, "objective3_cp")
Ambush("commander_spawn", 1, 3)
MapRemoveClassMarker("all_inf_rocketeer_jungle")
Objective3.OnComplete = function(self)
ClearAIGoals(DEF)
ClearAIGoals(3)
DeactivateRegion("loseregion1")
DeactivateRegion("death_objective")
end
end

SetUberMode(1)

EnableSPHeroRules()

end

function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 1.0 }
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective3)
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("dc:Load\\common.lvl")

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\\kam.lvl;kam1gcw")
ReadDataFile("dc:SIDE\\all.lvl",
"all_inf_rifleman_jungle",
"all_inf_rocketeer_jungle",
"all_inf_sniper_jungle",
"all_inf_engineer_jungle",
"all_hero_luke_jedi",
"",
"all_hero_hansolo_tat")

ReadDataFile("dc:SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_engineer",
"",
"imp_inf_sniper",
"imp_inf_officer",
"",
"imp_hero_bobafett",
"imp_hero_darthvader" )

ReadDataFile("dc:SIDE\\sniper.lvl",
"sniper_inf_sniper")

SetupTeams{
all = {
team = ALL,
units = 60,
reinforcements = -1,
soldier = { "all_inf_rifleman_jungle",9, 60},
assault = { "",1,20},
engineer = { "all_inf_engineer_jungle",1,20},
sniper = { "",0,0},
officer = { "",0,0},
special = { "",0,0},

},
imp = {
team = IMP,
units = 0,
reinforcements = 1,
soldier = { "sniper_inf_sniper",0, 0},
assault = { "",0,0},
engineer = { "",0,15},
sniper = { "",0,10},
officer = { "",0,15},
special = { "",0,1},
},
}

SetHeroClass(ALL, "")
SetHeroClass(IMP, "")

SetTeamName(3, "all")
AddUnitClass(3, "all_inf_rocketeer_jungle",1, 2)
SetUnitCount(3, 2)
SetReinforcementCount(3, -1)

SetTeamName(4, "all")
AddUnitClass(4, "all_inf_sniper_jungle",1, 2)
SetUnitCount(4, 2)
SetReinforcementCount(4, -1)

SetTeamAsFriend(3, ALL)
SetTeamAsFriend(ALL, 3)
SetTeamAsFriend(4, ALL)
SetTeamAsFriend(ALL, 4)
SetTeamAsEnemy(3, IMP)
SetTeamAsEnemy(IMP, 3)
SetTeamAsEnemy(4, IMP)
SetTeamAsEnemy(IMP, 4)
-- Level Stats
ClearWalkers()
AddWalkerType(0, 0) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 1) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)

local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("EntitySoundStream", 4)
SetMemoryPoolSize("EntitySoundStatic", 32)
SetMemoryPoolSize("MountedTurret", 32)
SetMemoryPoolSize("Navigator", 128)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("SoundSpaceRegion", 64)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("UnitAgent", 128)
SetMemoryPoolSize("UnitController", 128)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(10.0, 0.25)
ReadDataFile("dc:CHL\\CHL.lvl", "CHL_conquest")
SetDenseEnvironment("true")


-- Sound Stats

voiceSlow = OpenAudioStream("sound\\global.lvl", "all_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "des_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "all_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "gcw_music")
OpenAudioStream("sound\\kam.lvl", "kam1")
OpenAudioStream("sound\\kam.lvl", "kam1")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")

SetBleedingVoiceOver(ALL, ALL, "all_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(ALL, IMP, "all_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, ALL, "imp_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, IMP, "imp_off_com_report_us_overwhelmed", 1)

SetLowReinforcementsVoiceOver(ALL, ALL, "all_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(ALL, IMP, "all_off_victory_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, IMP, "imp_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, ALL, "imp_off_victory_im", .1, 1)

SetOutOfBoundsVoiceOver(2, "Allleaving")
SetOutOfBoundsVoiceOver(1, "Impleaving")

SetAmbientMusic(ALL, 1.0, "all_kam_amb_start", 0,1)
SetAmbientMusic(ALL, 0.8, "all_kam_amb_middle", 1,1)
SetAmbientMusic(ALL, 0.2, "all_kam_amb_end", 2,1)
SetAmbientMusic(IMP, 1.0, "imp_kam_amb_start", 0,1)
SetAmbientMusic(IMP, 0.8, "imp_kam_amb_middle", 1,1)
SetAmbientMusic(IMP, 0.2, "imp_kam_amb_end", 2,1)

SetVictoryMusic(ALL, "all_kam_amb_victory")
SetDefeatMusic (ALL, "all_kam_amb_defeat")
SetVictoryMusic(IMP, "imp_kam_amb_victory")
SetDefeatMusic (IMP, "imp_kam_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--SetSoundEffect("WeaponUnableSelect", "com_weap_inf_weaponchange_null")
--SetSoundEffect("WeaponModeUnableSelect", "com_weap_inf_modechange_null")
SetSoundEffect("SpawnDisplayUnitChange", "shell_select_unit")
SetSoundEffect("SpawnDisplayUnitAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change")
SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplayBack", "shell_menu_exit")

-- Camera Stats
--Tat2 Mos Eisley
AddCameraShot(0.974338, -0.222180, 0.035172, 0.008020, -82.664650, 23.668301, 43.955681);
AddCameraShot(0.390197, -0.089729, -0.893040, -0.205362, 23.563562, 12.914885, -101.465561);
AddCameraShot(0.169759, 0.002225, -0.985398, 0.012916, 126.972809, 4.039628, -22.020613);
AddCameraShot(0.677453, -0.041535, 0.733016, 0.044942, 97.517807, 4.039628, 36.853477);
AddCameraShot(0.866029, -0.156506, 0.467299, 0.084449, 7.685640, 7.130688, -10.895234);
end
end
Note: if I add the end in red the error log goes away but it still crashes ingame.

I even tried putting in a fresh conquest lua and just placing my objectives and side info in and it still does the same thing.

Re: Game doesn't like my lua?

Posted: Mon Mar 09, 2009 2:53 pm
by [RDH]Zerted
Your Objective3.OnStart function has one too many ends.

Re: Game doesn't like my lua?

Posted: Mon Mar 09, 2009 2:54 pm
by bobfinkl
Oh, wow that was a stupid mistake on my part. Thanks anyway Zerted it worked.