Page 1 of 1

lua problem [SOLVED]

Posted: Sat Dec 27, 2008 1:13 pm
by YaNkFaN
I am trying to make a campaign and this is my .lua with only a first objective i keep getting a ctd can anyone see anything wrong with it?
Hidden/Spoiler:
[quote]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_SetGameRules("Campaign")

-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;
AmbushTeam = 5
AMT= AmbushTeam

function ScriptPostLoad()

SetAIDifficulty(0, 2, "hard")
ScriptCB_SetGameRules("campaign")

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
)

--Head towards gunship objective #1 (attack)
Objective1 = ObjectiveGoto:New{TeamATT = ATT, -- objective made
text = "level.fel1.objectives.campaign.1", popupText = "level.fel1.objectives.campaign.1_popup", -- show objective on screen
regionName = "goto", 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) -- AI objective
end


--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"}
cp5 = CommandPost:New{name = "cp5"}
cp6 = CommandPost:New{name = "cp6"}
--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{textDEF = "game.modes.con2",
multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)

conquest:Start()

SetUberMode(1);



SetupAmbushTrigger("ambushregion", "ambushpath", 6, 3)

end

function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4.0 }
objectiveSequence:AddObjectiveSet(Objective1)
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(30)
SetMaxPlayerFlyHeight (30)

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\\yav.lvl;yav1cw")
ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_ep3_rifleman",
"rep_inf_ep3_rocketeer",
"rep_inf_ep3_engineer",
"rep_inf_ep3_sniper",
"rep_inf_ep3_officer",
"rep_inf_ep3_jettrooper",
"rep_hover_fightertank",
"rep_ep3_pilot",
"rep_walk_atte")
ReadDataFile("dc:SIDE\\cis.lvl",
"cis_inf_rifleman",
"cis_inf_rocketeer",
"cis_inf_engineer",
"cis_inf_sniper",
"cis_inf_officer",
"cis_inf_pilot",
"cis_inf_droideka",
"cis_inf_marine",
"cis_walk_spider")


ReadDataFile("dc:SIDE\\tur.lvl",
"tur_bldg_laser",
"tur_bldg_tower")

SetupTeams{
rep = {
team = REP,
units = 33,
reinforcements = 270,
soldier = { "rep_inf_ep3_rifleman",13, 13},
assault = { "rep_inf_ep3_pilot",3, 3},
engineer = { "rep_inf_ep3_engineer",4, 4},
sniper = { "rep_inf_ep3_sniper",4, 4},
officer = {"rep_inf_ep3_rocketeer",4, 4},
special = { "rep_inf_ep3_officer",2, 2},
extra1 = {"rep_inf_ep3_jettrooper",2,2},

},
cis = {
team = CIS,
units = 38,
reinforcements = 250,
soldier = { "cis_inf_marine",18, 18},
assault = { "cis_inf_pilot",4, 4},
engineer = { "cis_inf_engineer",4, 4},
sniper = { "cis_inf_sniper",3, 3},
officer = {"cis_inf_rocketeer",3, 3},
special = { "cis_inf_rifleman",3, 3},
extra1 = {"cis_inf_droideka", 2, 2},
},
atm = {
team = ATM,
units = 6,
reinforcements = -1,
soldier = { "cis_inf_rifleman",6, 6},
}

}

SetHeroClass(CIS, "cis_hero_darthmaul")
SetHeroClass(REP, "rep_hero_anakin")


-- Level Stats
-- ClearWalkers()
AddWalkerType(0, 4) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 2) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 2) -- 3x2 (3 pairs of legs)
local weaponCnt = 240
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("CommandWalker", 1)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 22)
SetMemoryPoolSize("EntityFlyer", 30)
SetMemoryPoolSize("EntityHover", 20)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("EntitySoundStream", 4)
SetMemoryPoolSize("EntitySoundStatic", 20)
SetMemoryPoolSize("MountedTurret", 25)
SetMemoryPoolSize("Navigator", 49)
SetMemoryPoolSize("Obstacle", 760)
SetMemoryPoolSize("PathNode", 512)
SetMemoryPoolSize("SoundSpaceRegion", 46)
SetMemoryPoolSize("TreeGridStack", 500)
SetMemoryPoolSize("UnitAgent", 49)
SetMemoryPoolSize("UnitController", 49)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(10.0, 0.25)
--ReadDataFile("dc:JFR\\JFR.lvl", "JFR_conquest")
ReadDataFile("dc:JFR\\JFR.lvl", "JFR_conquest")
SetDenseEnvironment("false")[/quote]
also all the regions are appropriately named as well as paths...

EDIT: also here is the only Severity 3 error in the BF2 log

Message Severity: 3
.\Source\HUDManager.cpp(619)
HUD unable to find HUD element type 0x16ce484a

Re: lua problem

Posted: Sat Dec 27, 2008 5:49 pm
by Master_Ben
YaNkFaN wrote:--Head towards gunship objective #1 (attack)
Objective1 = ObjectiveGoto:New{TeamATT = ATT, -- objective made
text = "level.fel1.objectives.campaign.1", popupText = "level.fel1.objectives.campaign.1_popup", -- show objective on screen
regionName = "goto", 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) -- AI objective
end
There's no "}" on the other side of the line. Good luck!

Off-Topic: Do any scripters actually use mission-scripter?

Re: lua problem

Posted: Sat Dec 27, 2008 6:09 pm
by YaNkFaN
YaNkFaN wrote:
--Head towards gunship objective #1 (attack)
Objective1 = ObjectiveGoto:New{TeamATT = ATT, -- objective made
text = "level.fel1.objectives.campaign.1", popupText = "level.fel1.objectives.campaign.1_popup", -- show objective on screen
regionName = "goto", 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) -- AI objective
end


There's no "}" on the other side of the line. Good luck!

Off-Topic: Do any scripters actually use mission-scripter?
isn't that the close bracket?

Re: lua problem

Posted: Sat Dec 27, 2008 6:18 pm
by Master_Ben
YaNkFaN wrote:isn't that the close bracket?
Oh, lol :oops: my mistake.

EDTI: Lol so I get a better idea of the big picture what is a ctd?

Re: lua problem

Posted: Sat Dec 27, 2008 6:28 pm
by YaNkFaN
ctd= crash to desktop...also i looked in the bf2 log error and there's nothing about luas or anything i've edited as well as the PC munge log error

there's another problem i got the first objective to work now the second isn't working here's the lua and here's the error
i know i'm not much of a scripter so i appreciate any help anyone could give

Code: Select all

C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\JFR\JFRc_con.lua:73: <eof> expected near `end'
ERROR[scriptmunge scripts\JFR\JFRc_con.lua]:Could not read input file.ERROR[scriptmunge scripts\JFR\JFRc_con.lua]:Could not read input file. [continuing]
   2 Errors    0 Warnings
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_SetGameRules("Campaign")

-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;
AmbushTeam = 5
ATM= AmbushTeam

function ScriptPostLoad()

SetAIDifficulty(0, 2, "hard")
ScriptCB_SetGameRules("campaign")


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
)

--Head towards gunship objective #1 (attack)
Objective1 = ObjectiveGoto:New{TeamATT = ATT, -- objective made
text = "level.JFR.1", popupText = "level.JFR.1_popup", -- show objective on screen
regionName = "goto", 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) -- AI objective
end

Objective1.OnComplete = function(self)
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(Objective1.defGoal1)
DeleteAIGoal(Objective1.defendGoal1)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 20)

end

Objective2CP = CommandPost:New{name = "cp6", hideCPs = false}
Objective1 = ObjectiveConquest:New{teamATT = DEF, teamDEF = ATT,
textDEF = "level.JFR.2",
popupText = "level.JFR.2_popup",
timeLimit = 180, timeLimitWinningTeam = ATT}
Objective2:AddCommandPost(Objective2CP)
SetProperty("cp6", "Value_DEF_CIS", "2000")
MapAddEntityMarker("cp6", "hud_objective_icon", 3.0, 1, "YELLOW", true)
end
Objective2.OnComplete = function(self)
MapRemoveEntityMarker("cp6")
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 20)
SetProperty("cp6", "AISpawnWeight", "1000")
if self.winningTeam == DEF then
ScriptCB_SndPlaySound("KAS_inf_01")
else
end
end


--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"}
cp5 = CommandPost:New{name = "cp5"}
cp6 = CommandPost:New{name = "cp6"}
--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{textDEF = "game.modes.con2",
multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)

conquest:Start()

SetUberMode(1);



SetupAmbushTrigger("ambushregion", "ambushpath", 6, 5)

end

function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4.0}
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2CP)
objectiveSequence:Start()

end
the stuff i edited starts with Objective 2 CP

Re: lua problem

Posted: Sun Dec 28, 2008 12:01 pm
by Master_Ben
Ok, so this:
YaNkFaN wrote:

Code: Select all

C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\JFR\JFRc_con.lua:73: <eof> expected near `end'
ERROR[scriptmunge scripts\JFR\JFRc_con.lua]:Could not read input file.ERROR[scriptmunge scripts\JFR\JFRc_con.lua]:Could not read input file. [continuing]
   2 Errors    0 Warnings
Means there's an unexpected "<eof>" (whatever that is) at line 73 (in blue):
Hidden/Spoiler:
Objective2CP = CommandPost:New{name = "cp6", hideCPs = false}
Objective1 = ObjectiveConquest:New{teamATT = DEF, teamDEF = ATT,
textDEF = "level.JFR.2",
popupText = "level.JFR.2_popup",
timeLimit = 180, timeLimitWinningTeam = ATT}
Objective2:AddCommandPost(Objective2CP)
SetProperty("cp6", "Value_DEF_CIS", "2000")
MapAddEntityMarker("cp6", "hud_objective_icon", 3.0, 1, "YELLOW", true)
end
Objective2.OnComplete = function(self)
MapRemoveEntityMarker("cp6")
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 20)
SetProperty("cp6", "AISpawnWeight", "1000")
if self.winningTeam == DEF then
ScriptCB_SndPlaySound("KAS_inf_01")
else
end
end
So there's a problem there. For some scripts, I use Mission-Scripter. It eliminates a lot of scripting errors. Don't use it all the time, it only supports a couple o' objectives. :o

Re: lua problem

Posted: Sun Dec 28, 2008 12:04 pm
by Aman/Pinguin
Master_Ben wrote:Means there's an unexpected "<eof>" (whatever that is)

eof = end of file

Re: lua problem

Posted: Sun Dec 28, 2008 12:05 pm
by Maveritchell
You redefined "Objective1" when you should be working on "Objective2." You might also have an extra "end," but I didn't check for that.

Re: lua problem

Posted: Sun Dec 28, 2008 12:30 pm
by YaNkFaN
i fixed it and went on to objective 3 so everything is good this can be locked