Problems with the Race mode Script
Posted: Sun Mar 14, 2010 10:58 am
by Redline
Hello everyone i have a big problem with the race script from Maveritchell, but first before i go on with my problem i have to ask u all " Does it ever work for someone?"
Maveritchell told me it shall work, because it's a copy of the original race script and this script should work.
However Maveritchell said it works.
But how if there are some mistakes inside the script?
Anyway my problem is that Visual munge shows me many closing or symbol problems like an end is missing or a symbole like this = .
However I fixed many unclosed functions, but visual munge gives me one problem after the other one.
Here is an exsample where i don't know what visual munge want of me.
Oh and I have to mention that i did every the steps of Maveritchell, but to my opinion this script can't be correct in any way.
If you do not believe me, try it out or find a solution way so that i can see what i have done wrong.
My script lua:
Here you can see the instruction and i checked all steps with a done or something else:
Maveritchell told me it shall work, because it's a copy of the original race script and this script should work.
However Maveritchell said it works.
But how if there are some mistakes inside the script?
Anyway my problem is that Visual munge shows me many closing or symbol problems like an end is missing or a symbole like this = .
However I fixed many unclosed functions, but visual munge gives me one problem after the other one.
Here is an exsample where i don't know what visual munge want of me.
Hidden/Spoiler:
[code]E:\Programme\BF2_ModTools\data_RRS\_BUILD\Common\..\..\..\ToolsFL\Bin\luac.exe: ..\..\common\scripts\RRS\RRSc_ctf.lua:89: `=' expected near `)'
ERROR[scriptmunge scripts\RRS\RRSc_ctf.lua]:Could not read input file.ERROR[scriptmunge scripts\RRS\RRSc_ctf.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
[/code]
ERROR[scriptmunge scripts\RRS\RRSc_ctf.lua]:Could not read input file.ERROR[scriptmunge scripts\RRS\RRSc_ctf.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings
[/code]
If you do not believe me, try it out or find a solution way so that i can see what i have done wrong.
My script lua:
Hidden/Spoiler:
[code]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
-- load the gametype script
Conquest = ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveTDM")
-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;
---------------------------------------------------------------------------
-- ScriptPostLoad
---------------------------------------------------------------------------
function ScriptPostLoad()
EnableSPHeroRules()
-- This is the actual objective setup
TDM = ObjectiveTDM:New{teamATT = 1, teamDEF = 2,
multiplayerScoreLimit = 100,
textATT = "game.modes.tdm",
textDEF = "game.modes.tdm2", multiplayerRules = true, isCelebrityDeathmatch = true}
TDM:Start()
AddAIGoal(1, "Deathmatch", 100)
AddAIGoal(2, "Deathmatch", 100)
--------------------------RACE MODE----------------------
--this section gives each of the undefined variables a zero value, and then kills itself.
ActivateRegion("InitRegion")
RacerCount = 0
trigger1 = 0
trigger2 = 0
trigger3 = 0
trigger4 = 0
trigger5 = 0
trigger6 = 0
trigger7 = 0
trigger8 = 0
racer1laps = 0
racer2laps = 0
racer3laps = 0
racer4laps = 0
racer5laps = 0
racer6laps = 0
racer7laps = 0
racer8laps = 0
finished = 0
region16 = OnEnterRegion(
function(region, player)
if trigger1 == 0 then
print("initialized")
StartTimer("Race")
DeactivateRegion("InitRegion")
"InitRegion"
end
end)
--Sets timer for the race; set to 5:00 here
RaceTimer = CreateTimer("Race")
SetTimerValue(RaceTimer, 320)
ShowTimer(RaceTimer)
OnTimerElapse(
function(timer)
MissionVictory(ATT)
ShowTimer(nil)
DestroyTimer(timer)
RaceTimer)
end
--this section creates a region at the start/finish line that defines each player as a certain racer
ActivateRegion("StartLineRegion")
region1 = OnEnterRegion(
function(region, player)
if RacerCount == 0 then
racer1 = player
RacerCount = RacerCount +1
print("startlineregion1 triggered")
elseif RacerCount == 1 and racer1 ~= player then
racer2 = player
RacerCount = RacerCount +1
print("startlineregion2 triggered")
elseif RacerCount == 2 and racer1 ~= player and racer2 ~= player then
racer3 = player
RacerCount = RacerCount +1
print("startlineregion3 triggered")
elseif RacerCount == 3 and racer1 ~= player and racer2 ~= player and racer3 ~= player then
racer4 = player
RacerCount = RacerCount +1
print("startlineregion4 triggered")
elseif RacerCount == 4 and racer1 ~= player and racer2 ~= player and racer3 ~= player and racer4 ~= player then
racer5 = player
RacerCount = RacerCount +1
print("startlineregion5 triggered")
elseif RacerCount == 5 and racer1 ~= player and racer2 ~= player and racer3 ~= player and racer4 ~= player and racer5 ~= player then
racer6 = player
RacerCount = RacerCount +1
print("startlineregion6 triggered")
elseif RacerCount == 6 and racer1 ~= player and racer2 ~= player and racer3 ~= player and racer4 ~= player and racer5 ~= player and racer6 ~= player then
racer7 = player
RacerCount = RacerCount +1
elseif RacerCount == 7 and racer1 ~= player and racer2 ~= player and racer3 ~= player and racer4 ~= player and racer5 ~= player and racer6 ~= player and racer7 ~= player then
racer8 = player
RacerCount = RacerCount +1
elseif RacerCount == 8 then
DeactivateRegion("StartLineRegion")
--Makes it so this function never triggers again since none of the if/elseif statments ('cept this one) will ever
--be satusfied again, and would just waste CPU power confirming that. This is the only reason why these functions
--aren't in the other event is because of this. All the other checks/point givings were checked each time at the race end
--anway (and still are)
"StartLineRegion"
end
end
--Executes multiple checks and tasks when a player crosses the finishline
ActivateRegion("FinishLineRegion")
region2 = OnEnterRegion(
function(region, player)
--this section creates a tally for each racer based on how many laps they've completed, also at the start/finish line
if racer1 == player and trigger1 == 1 then
racer1laps = racer1laps + 1
trigger1 = 0
print("onelapcompletedr1")
elseif racer2 == player and trigger2 == 1 then
racer2laps = racer2laps + 1
trigger2 = 0
elseif racer3 == player and trigger3 == 1 then
racer3laps = racer3laps + 1
trigger3 = 0
elseif racer4 == player and trigger4 == 1 then
racer4laps = racer4laps + 1
trigger4 = 0
elseif racer5 == player and trigger5 == 1 then
racer5laps = racer5laps + 1
trigger5 = 0
elseif racer6 == player and trigger6 == 1 then
racer6laps = racer6laps + 1
trigger6 = 0
elseif racer7 == player and trigger7 == 1 then
racer7laps = racer7laps + 1
trigger7 = 0
elseif racer8 == player and trigger8 == 1 then
racer8laps = racer8laps + 1
trigger8 = 0
end
--this section gives points based on whether the
--player has finished 5 laps and on how much time is left
--Assigns points to the player if they have completed 5 laps.
--If player is racer 1
if racer1 == player and racer1laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer1)
racetime = racetime - 1
end
racer1laps = 6
--If player is racer 2
elseif racer2 == player and racer2laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer2)
racetime = racetime - 1
end
racer2laps = 6
--If player is racer 3
elseif racer3 == player and racer3laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer3)
racetime = racetime - 1
end
racer3laps = 6
--If player is racer 4
elseif racer4 == player and racer4laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer4)
racetime = racetime - 1
end
racer4laps = 6
elseif racer5 == player and racer5laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer5)
racetime = racetime - 1
end
racer5laps = 6
elseif racer6 == player and racer6laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer7)
racetime = racetime - 1
end
racer6laps = 6
elseif racer7 == player and racer7laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer7)
racetime = racetime - 1
end
racer7laps = 6
elseif racer8 == player and racer8laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer8)
racetime = racetime - 1
end
racer8laps = 6
--This section ends the map if all 8 racers have crossed the finish line after 5 laps
if racer1laps + racer2laps + racer3laps + racer4laps + racer5laps + racer6laps + racer7laps + racer8laps + racer9laps + racer10laps == 50 then
MissionVictory(1)
"FinishLineRegion"
end
end
--this section indicates that a player has finished a lap, so that a tally can be eventually added to their lapcount
ActivateRegion("TriggerRegion")
region15 = OnEnterRegion(
function(region, player)
if trigger1 == 0 and racer1 == player then
trigger1 = 1
print("triggered")
elseif trigger2 == 0 and racer2 == player then
trigger2 = 1
print("triggered2")
elseif trigger3 == 0 and racer3 == player then
trigger3 = 1
print("triggered3")
elseif trigger4 == 0 and racer4 == player then
trigger4 = 1
print("triggered4")
elseif trigger5 == 0 and racer5 == player then
trigger5 = 1
print("triggered")
elseif trigger6 == 0 and racer6 == player then
trigger6 = 1
print("triggered")
elseif trigger7 == 0 and racer7 == player then
trigger7 = 1
print("triggered")
elseif trigger8 == 0 and racer8 == player then
trigger8 = 1
print("triggered")
elseif trigger9 == 0 and racer9 == player then
trigger9 = 1
print("triggered")
elseif trigger10 == 0 and racer10 == player then
trigger10 = 1
print("triggered")
"TriggerRegion"
end
-------------------------END OF RACE MODE------------------------
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.
---------------------------------------------------------------------------[/code]
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
-- load the gametype script
Conquest = ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveTDM")
-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;
---------------------------------------------------------------------------
-- ScriptPostLoad
---------------------------------------------------------------------------
function ScriptPostLoad()
EnableSPHeroRules()
-- This is the actual objective setup
TDM = ObjectiveTDM:New{teamATT = 1, teamDEF = 2,
multiplayerScoreLimit = 100,
textATT = "game.modes.tdm",
textDEF = "game.modes.tdm2", multiplayerRules = true, isCelebrityDeathmatch = true}
TDM:Start()
AddAIGoal(1, "Deathmatch", 100)
AddAIGoal(2, "Deathmatch", 100)
--------------------------RACE MODE----------------------
--this section gives each of the undefined variables a zero value, and then kills itself.
ActivateRegion("InitRegion")
RacerCount = 0
trigger1 = 0
trigger2 = 0
trigger3 = 0
trigger4 = 0
trigger5 = 0
trigger6 = 0
trigger7 = 0
trigger8 = 0
racer1laps = 0
racer2laps = 0
racer3laps = 0
racer4laps = 0
racer5laps = 0
racer6laps = 0
racer7laps = 0
racer8laps = 0
finished = 0
region16 = OnEnterRegion(
function(region, player)
if trigger1 == 0 then
print("initialized")
StartTimer("Race")
DeactivateRegion("InitRegion")
"InitRegion"
end
end)
--Sets timer for the race; set to 5:00 here
RaceTimer = CreateTimer("Race")
SetTimerValue(RaceTimer, 320)
ShowTimer(RaceTimer)
OnTimerElapse(
function(timer)
MissionVictory(ATT)
ShowTimer(nil)
DestroyTimer(timer)
RaceTimer)
end
--this section creates a region at the start/finish line that defines each player as a certain racer
ActivateRegion("StartLineRegion")
region1 = OnEnterRegion(
function(region, player)
if RacerCount == 0 then
racer1 = player
RacerCount = RacerCount +1
print("startlineregion1 triggered")
elseif RacerCount == 1 and racer1 ~= player then
racer2 = player
RacerCount = RacerCount +1
print("startlineregion2 triggered")
elseif RacerCount == 2 and racer1 ~= player and racer2 ~= player then
racer3 = player
RacerCount = RacerCount +1
print("startlineregion3 triggered")
elseif RacerCount == 3 and racer1 ~= player and racer2 ~= player and racer3 ~= player then
racer4 = player
RacerCount = RacerCount +1
print("startlineregion4 triggered")
elseif RacerCount == 4 and racer1 ~= player and racer2 ~= player and racer3 ~= player and racer4 ~= player then
racer5 = player
RacerCount = RacerCount +1
print("startlineregion5 triggered")
elseif RacerCount == 5 and racer1 ~= player and racer2 ~= player and racer3 ~= player and racer4 ~= player and racer5 ~= player then
racer6 = player
RacerCount = RacerCount +1
print("startlineregion6 triggered")
elseif RacerCount == 6 and racer1 ~= player and racer2 ~= player and racer3 ~= player and racer4 ~= player and racer5 ~= player and racer6 ~= player then
racer7 = player
RacerCount = RacerCount +1
elseif RacerCount == 7 and racer1 ~= player and racer2 ~= player and racer3 ~= player and racer4 ~= player and racer5 ~= player and racer6 ~= player and racer7 ~= player then
racer8 = player
RacerCount = RacerCount +1
elseif RacerCount == 8 then
DeactivateRegion("StartLineRegion")
--Makes it so this function never triggers again since none of the if/elseif statments ('cept this one) will ever
--be satusfied again, and would just waste CPU power confirming that. This is the only reason why these functions
--aren't in the other event is because of this. All the other checks/point givings were checked each time at the race end
--anway (and still are)
"StartLineRegion"
end
end
--Executes multiple checks and tasks when a player crosses the finishline
ActivateRegion("FinishLineRegion")
region2 = OnEnterRegion(
function(region, player)
--this section creates a tally for each racer based on how many laps they've completed, also at the start/finish line
if racer1 == player and trigger1 == 1 then
racer1laps = racer1laps + 1
trigger1 = 0
print("onelapcompletedr1")
elseif racer2 == player and trigger2 == 1 then
racer2laps = racer2laps + 1
trigger2 = 0
elseif racer3 == player and trigger3 == 1 then
racer3laps = racer3laps + 1
trigger3 = 0
elseif racer4 == player and trigger4 == 1 then
racer4laps = racer4laps + 1
trigger4 = 0
elseif racer5 == player and trigger5 == 1 then
racer5laps = racer5laps + 1
trigger5 = 0
elseif racer6 == player and trigger6 == 1 then
racer6laps = racer6laps + 1
trigger6 = 0
elseif racer7 == player and trigger7 == 1 then
racer7laps = racer7laps + 1
trigger7 = 0
elseif racer8 == player and trigger8 == 1 then
racer8laps = racer8laps + 1
trigger8 = 0
end
--this section gives points based on whether the
--player has finished 5 laps and on how much time is left
--Assigns points to the player if they have completed 5 laps.
--If player is racer 1
if racer1 == player and racer1laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer1)
racetime = racetime - 1
end
racer1laps = 6
--If player is racer 2
elseif racer2 == player and racer2laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer2)
racetime = racetime - 1
end
racer2laps = 6
--If player is racer 3
elseif racer3 == player and racer3laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer3)
racetime = racetime - 1
end
racer3laps = 6
--If player is racer 4
elseif racer4 == player and racer4laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer4)
racetime = racetime - 1
end
racer4laps = 6
elseif racer5 == player and racer5laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer5)
racetime = racetime - 1
end
racer5laps = 6
elseif racer6 == player and racer6laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer7)
racetime = racetime - 1
end
racer6laps = 6
elseif racer7 == player and racer7laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer7)
racetime = racetime - 1
end
racer7laps = 6
elseif racer8 == player and racer8laps == 5 then
racetime = GetTimerValue("Race")
while racetime > 0 do
AddFlagCapturePoints(racer8)
racetime = racetime - 1
end
racer8laps = 6
--This section ends the map if all 8 racers have crossed the finish line after 5 laps
if racer1laps + racer2laps + racer3laps + racer4laps + racer5laps + racer6laps + racer7laps + racer8laps + racer9laps + racer10laps == 50 then
MissionVictory(1)
"FinishLineRegion"
end
end
--this section indicates that a player has finished a lap, so that a tally can be eventually added to their lapcount
ActivateRegion("TriggerRegion")
region15 = OnEnterRegion(
function(region, player)
if trigger1 == 0 and racer1 == player then
trigger1 = 1
print("triggered")
elseif trigger2 == 0 and racer2 == player then
trigger2 = 1
print("triggered2")
elseif trigger3 == 0 and racer3 == player then
trigger3 = 1
print("triggered3")
elseif trigger4 == 0 and racer4 == player then
trigger4 = 1
print("triggered4")
elseif trigger5 == 0 and racer5 == player then
trigger5 = 1
print("triggered")
elseif trigger6 == 0 and racer6 == player then
trigger6 = 1
print("triggered")
elseif trigger7 == 0 and racer7 == player then
trigger7 = 1
print("triggered")
elseif trigger8 == 0 and racer8 == player then
trigger8 = 1
print("triggered")
elseif trigger9 == 0 and racer9 == player then
trigger9 = 1
print("triggered")
elseif trigger10 == 0 and racer10 == player then
trigger10 = 1
print("triggered")
"TriggerRegion"
end
-------------------------END OF RACE MODE------------------------
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.
---------------------------------------------------------------------------[/code]
Hidden/Spoiler:
[code]Star Wars Battlefront II: Race Mode
by Maveritchell
---
This script is designed to be added into an already-working .lua script for SWBF2. If you don't know how to work with .lua scripts, you should probably stop now, learn, and come back to this later. Assuming you do, you just insert the script in this .zip file right into your .lua (I prefer to use an Assault .lua) right above the ScriptInit function, in ScriptPostLoad, as shown in the included script excerpt.
Notes:
1) You need to have set up a circuitous track in which the racers can only go one direction. I used invisible collision boxes to do this, although you may set yours up in a different way. done!
2) The region "TriggerRegion" is important. To prevent people from just crossing the finish line repeatedly without going around the whole track, they must trigger a certain variable, which, when enabled, allows their lapcount to go up. This variable is triggered by "TriggerRegion." As such you must make this region available only once per lap. You can do this in one of two (maybe more?) ways:
a)You can make this region exactly halfway around the track, meaning that a person has to do at least the distance of one lap to get to it. i chose this and done!
b)You can make the region at the very end of the track. If you make the region here, you need to make it impossible to go backwards and get to this region. I used this in Ralltiir: Swoop Circuit, and did this by making a jump down to the finish line. You can go forwards (down) through this, but not backwards (up).
3)The other regions must be set up in this order: (as seen in the included .jpegs, ordered ss1, ss2, ss4)
-InitRegion (must be fir!st, and must be hit before the first lap starts) done!
-FinishLineRegion done!
-StartLineRegion done!
-please note that these regions can overlap, just so long as they are entered in this order and they will be entered sequentially. i noted!
4) The timer can be easily changed, all you need to do is edit the number in this line:
SetTimerValue(RaceTimer, 420) The number represents the number of seconds you have to race. done!
5) You can reduce the number of racers allowed by (in addition to editing the side to allow only so many players) removing the sections in the script that call for the regions to "GiveXPoints." E.g., if you wanted to have only 8 racers, you would remove the sections in the code to refer to "Give9Points" and "Give10Points." The number of racers can be increased, but to do so you would need to add new regions for them and add the appropriate sections into the code. You can probably figure this out just by looking over the code. /Also done, because i use 8 players
---
Credits:
Jesus Christ, my God and my Friend
Ace_Azzameen_5, who was an invaluable resource helping me out with some of this coding, and who also took my original racemode code and cleaned it up so that it wasn't quite as messy in your .lua
Gametoast.com community, without whose resources I wouldn't have gotten started on this
---
Questions? E-mail me at [email protected]
Thanks! Enjoy.[/code]
by Maveritchell
---
This script is designed to be added into an already-working .lua script for SWBF2. If you don't know how to work with .lua scripts, you should probably stop now, learn, and come back to this later. Assuming you do, you just insert the script in this .zip file right into your .lua (I prefer to use an Assault .lua) right above the ScriptInit function, in ScriptPostLoad, as shown in the included script excerpt.
Notes:
1) You need to have set up a circuitous track in which the racers can only go one direction. I used invisible collision boxes to do this, although you may set yours up in a different way. done!
2) The region "TriggerRegion" is important. To prevent people from just crossing the finish line repeatedly without going around the whole track, they must trigger a certain variable, which, when enabled, allows their lapcount to go up. This variable is triggered by "TriggerRegion." As such you must make this region available only once per lap. You can do this in one of two (maybe more?) ways:
a)You can make this region exactly halfway around the track, meaning that a person has to do at least the distance of one lap to get to it. i chose this and done!
b)You can make the region at the very end of the track. If you make the region here, you need to make it impossible to go backwards and get to this region. I used this in Ralltiir: Swoop Circuit, and did this by making a jump down to the finish line. You can go forwards (down) through this, but not backwards (up).
3)The other regions must be set up in this order: (as seen in the included .jpegs, ordered ss1, ss2, ss4)
-InitRegion (must be fir!st, and must be hit before the first lap starts) done!
-FinishLineRegion done!
-StartLineRegion done!
-please note that these regions can overlap, just so long as they are entered in this order and they will be entered sequentially. i noted!
4) The timer can be easily changed, all you need to do is edit the number in this line:
SetTimerValue(RaceTimer, 420) The number represents the number of seconds you have to race. done!
5) You can reduce the number of racers allowed by (in addition to editing the side to allow only so many players) removing the sections in the script that call for the regions to "GiveXPoints." E.g., if you wanted to have only 8 racers, you would remove the sections in the code to refer to "Give9Points" and "Give10Points." The number of racers can be increased, but to do so you would need to add new regions for them and add the appropriate sections into the code. You can probably figure this out just by looking over the code. /Also done, because i use 8 players
---
Credits:
Jesus Christ, my God and my Friend
Ace_Azzameen_5, who was an invaluable resource helping me out with some of this coding, and who also took my original racemode code and cleaned it up so that it wasn't quite as messy in your .lua
Gametoast.com community, without whose resources I wouldn't have gotten started on this
---
Questions? E-mail me at [email protected]
Thanks! Enjoy.[/code]