Random Weather code [Solved]

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
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Random Weather code [Solved]

Post 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
Last edited by fiddler_on_the_roof on Fri Aug 06, 2010 5:40 pm, edited 1 time in total.
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: Random Weather code

Post 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
fiddler_on_the_roof
1st Lieutenant
1st Lieutenant
Posts: 460
Joined: Wed Nov 12, 2008 5:28 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: Random Weather code

Post by fiddler_on_the_roof »

thanks so much!! it worked
Post Reply