Page 1 of 1

Random Weather code [Solved]

Posted: Fri Aug 06, 2010 4:19 pm
by fiddler_on_the_roof
i am trying to add 2 random skies to my map, but it tells me that the code is wrong, and needs an end to the function

lua:
Hidden/Spoiler:
[code]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("setup_teams")

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


function ScriptPostLoad()

WeatherMode = math.random(1,2)
weather()

--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{teamATT = ATT, teamDEF = DEF,
textATT = "game.modes.con",
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()

EnableSPHeroRules()

end


function weather()
elseif WeatherMode == 1 then
ReadDataFile("dc:ICC\\sky.lvl", "clear")
elseif WeatherMode == 2 then
ReadDataFile("dc:ICC\\sky.lvl", "rainy")
end
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()[/code]
mungelog
Hidden/Spoiler:
[code]C:\BF2_ModTools\data_ICC\_BUILD\Common\..\..\..\ToolsFL\Bin\luac.exe: ..\..\common\scripts\ICC\ICCc_con.lua:54: `end' expected (to close `function' at line 53) near `elseif'
ERROR[scriptmunge scripts\ICC\ICCc_con.lua]:Could not read input file.ERROR[scriptmunge scripts\ICC\ICCc_con.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings

[/code]
i've tried several variations of the function weather, but still nothing

Re: Random Weather code

Posted: Fri Aug 06, 2010 4:54 pm
by Teancum
function weather()
elseif WeatherMode == 1 then
ReadDataFile("dc:ICC\\sky.lvl", "clear")
elseif WeatherMode == 2 then
ReadDataFile("dc:ICC\\sky.lvl", "rainy")
end
end
Should just be if

Re: Random Weather code

Posted: Fri Aug 06, 2010 5:40 pm
by fiddler_on_the_roof
thanks so much!! it worked