Skip to content

Commit 2ade5eb

Browse files
committed
Script cleanup, unify debug logging
1 parent 20c03ae commit 2ade5eb

32 files changed

+995
-718
lines changed

ME5/EURn_c.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,6 @@ function SetSquadCanKillEnemies(canKill) -- TODO: fix function tbh
17181718
for curTeam in ipairs(enemyTeams) do
17191719
local teamSize = GetTeamSize(curTeam)
17201720
if teamSize > 0 then
1721-
print()
17221721
print("SetSquadCanKillEnemies(): curTeam:", enemyTeams[curTeam])
17231722

17241723
if canKill == false then

ME5_AudioFunctions.lua

Lines changed: 74 additions & 65 deletions
Large diffs are not rendered by default.

ME5_CameraManager.lua

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@
6666
-- THIS SCRIPT IS NOT MADE, DISTRIBUTED, OR SUPPORTED BY LUCASARTS, A DIVISION OF LUCASFILM ENTERTAINMENT COMPANY LTD.
6767
-----------------------------------------------------------------
6868
-----------------------------------------------------------------
69-
print("ME5_CameraManager: Entered")
69+
local __SCRIPT_NAME = "ME5_CameraManager";
70+
local debug = true
71+
72+
local function PrintLog(...)
73+
if debug == true then
74+
print("["..__SCRIPT_NAME.."]", unpack(arg));
75+
end
76+
end
77+
78+
PrintLog("Entered")
7079

7180
---
7281
-- This is a constructor for a CameraShot object.
@@ -134,21 +143,21 @@ end
134143
function CameraShot:Start()
135144
-- Is the camera's class name set? If not, print an error message and exit the function
136145
if self.cameraClassName == nil then
137-
print("CameraShot:Start(): WARNING: cameraClassName must be specified! Exiting function")
146+
PrintLog("CameraShot:Start(): WARNING: cameraClassName must be specified! Exiting function")
138147
return
139148
end
140149

141150
-- Is the camera's object name set? If not, print an error message and exit the function
142151
if self.cameraObj == nil then
143-
print("CameraShot:Start(): WARNING: cameraObj must be specified! Exiting function")
152+
PrintLog("CameraShot:Start(): WARNING: cameraObj must be specified! Exiting function")
144153
return
145154
end
146155

147156
-- Is this shot being put into a container?
148157
if not self.container then
149158
-- Is the path name set? If not, print an error message and exit the function
150159
if self.pathName == nil then
151-
print("CameraShot:Start(): WARNING: pathName must be specified if not using a container! Exiting function")
160+
PrintLog("CameraShot:Start(): WARNING: pathName must be specified if not using a container! Exiting function")
152161
return
153162
end
154163
end
@@ -360,4 +369,4 @@ function CameraShot:Complete()
360369
self:OnComplete()
361370
end
362371

363-
print("ME5_CameraManager: Exited")
372+
PrintLog("Exited")

ME5_CinematicContainer.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@
5151
-- THIS SCRIPT IS NOT MADE, DISTRIBUTED, OR SUPPORTED BY LUCASARTS, A DIVISION OF LUCASFILM ENTERTAINMENT COMPANY LTD.
5252
-----------------------------------------------------------------
5353
-----------------------------------------------------------------
54-
print("ME5_CinematicContainer: Entered")
54+
local __SCRIPT_NAME = "ME5_CinematicContainer";
55+
local debug = true
56+
57+
local function PrintLog(...)
58+
if debug == true then
59+
print("["..__SCRIPT_NAME.."]", unpack(arg));
60+
end
61+
end
62+
63+
PrintLog("Entered")
5564

5665
---
5766
-- This is a constructor for a CinematicContainer object.
@@ -112,7 +121,7 @@ end
112121
--
113122
function CinematicContainer:Start()
114123
if self.pathName == nil then
115-
print("CinematicContainer:Start(): WARNING: pathName must be specified!")
124+
PrintLog("Start(): WARNING: pathName must be specified!")
116125
return
117126
end
118127

@@ -121,7 +130,7 @@ function CinematicContainer:Start()
121130

122131
local numShots = table.getn(self.shotSets)
123132
if(numShots == 0) then
124-
print("CinematicContainer:Start(): WARNING: No shots were added to the CinematicContainer")
133+
PrintLog("Start(): WARNING: No shots were added to the CinematicContainer")
125134
return
126135
end
127136

@@ -187,4 +196,4 @@ function CinematicContainer:Complete()
187196
self:OnComplete()
188197
end
189198

190-
print("ME5_CinematicContainer: Exited")
199+
PrintLog("Exited")

ME5_CombatManager.lua

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,16 @@
7474
-----------------------------------------------------------------
7575
-----------------------------------------------------------------
7676

77-
print("ME5_CombatManager: Entered")
77+
local __SCRIPT_NAME = "ME5_CombatManager";
78+
local debug = true
79+
80+
local function PrintLog(...)
81+
if debug == true then
82+
print("["..__SCRIPT_NAME.."]", unpack(arg));
83+
end
84+
end
85+
86+
PrintLog("Entered")
7887

7988

8089
--=================================
@@ -142,7 +151,7 @@ function WaveSequence:AddWave(...)
142151
-- Update totalEnemies with the number of enemies that are spawned in the wave
143152
self.totalEnemies = self.totalEnemies + wave.numDudes
144153

145-
print("WaveSequence:AddWave(): totalEnemies:", self.totalEnemies)
154+
PrintLog("WaveSequence:AddWave(): totalEnemies:", self.totalEnemies)
146155
end
147156

148157
table.insert(self.waveSets, arg)
@@ -162,7 +171,7 @@ end
162171
-- Call this to activate the first wave and initialize event logic.
163172
--
164173
function WaveSequence:Start(combatZoneID, musicID)
165-
print("WaveSequence:Start(): Starting combat zone")
174+
PrintLog("WaveSequence:Start(): Starting combat zone")
166175

167176
-- Initialize values for data fields (even if they don't exist)
168177
--self.pathNode = self.pathNode or 0
@@ -171,7 +180,7 @@ function WaveSequence:Start(combatZoneID, musicID)
171180
-- Store the number of waves in this sequence
172181
self.totalWaves = table.getn(self.waveSets)
173182
if(self.totalWaves == 0) then
174-
print("WaveSequence:Start(): WARNING: No waves were added to the WaveSequence")
183+
PrintLog("WaveSequence:Start(): WARNING: No waves were added to the WaveSequence")
175184
return
176185
end
177186

@@ -232,7 +241,7 @@ function WaveSequence:Start(combatZoneID, musicID)
232241

233242
-- Increment the kill count
234243
self.killCount = self.killCount + 1
235-
print("WaveSequence:Start(): killCount:", self.killCount)
244+
PrintLog("WaveSequence:Start(): killCount:", self.killCount)
236245

237246

238247
-- Have all the enemies been killed?
@@ -282,15 +291,15 @@ end
282291
-- Updates the current wave set number, and activates all the waves within that set.
283292
--
284293
function WaveSequence:ActivateWaveSet(whichSet)
285-
print("WaveSequence:ActivateWaveSet(): Spawning wave "..whichSet)
294+
PrintLog("WaveSequence:ActivateWaveSet(): Spawning wave "..whichSet)
286295

287296
-- Is debug messages enabled?
288297
if self.bDebug == true then
289298
ShowMessageText("level.EUR.debug.comzone_spawning", REP)
290299
end
291300

292301
if whichSet == table.getn(self.waveSets) then
293-
print("EURn_c.SpawnNextWave(): NOTICE: Final wave")
302+
PrintLog("EURn_c.SpawnNextWave(): NOTICE: Final wave")
294303

295304
-- Is debug messages enabled?
296305
if self.bDebug == true then
@@ -322,7 +331,7 @@ end
322331
-- Call this to complete the wave sequence.
323332
--
324333
function WaveSequence:Complete()
325-
print("WaveSequence:Complete(): Combat zone cleared")
334+
PrintLog("WaveSequence:Complete(): Combat zone cleared")
326335

327336
-- Is debug messages enabled?
328337
if bDebug == true then
@@ -390,23 +399,23 @@ function SmartSpawn:Start()
390399

391400
-- Initialize data fields
392401
if self.regionName == nil then
393-
print("SmartSpawn:Start(): WARNING: regionName must be specified! Exiting function")
402+
PrintLog("SmartSpawn:Start(): WARNING: regionName must be specified! Exiting function")
394403
return
395404
end
396405
if self.allySpawnIn == nil then
397-
print("SmartSpawn:Start(): WARNING: allySpawnIn must be specified! Exiting function")
406+
PrintLog("SmartSpawn:Start(): WARNING: allySpawnIn must be specified! Exiting function")
398407
return
399408
end
400409
if self.allySpawnOut == nil then
401-
print("SmartSpawn:Start(): WARNING: allySpawnOut must be specified! Exiting function")
410+
PrintLog("SmartSpawn:Start(): WARNING: allySpawnOut must be specified! Exiting function")
402411
return
403412
end
404413
if self.enemySpawnIn == nil then
405-
print("SmartSpawn:Start(): WARNING: enemySpawnIn must be specified! Exiting function")
414+
PrintLog("SmartSpawn:Start(): WARNING: enemySpawnIn must be specified! Exiting function")
406415
return
407416
end
408417
if self.enemySpawnOut == nil then
409-
print("SmartSpawn:Start(): WARNING: enemySpawnOut must be specified! Exiting function")
418+
PrintLog("SmartSpawn:Start(): WARNING: enemySpawnOut must be specified! Exiting function")
410419
return
411420
end
412421

@@ -455,7 +464,7 @@ function SmartSpawn:Start()
455464
self.playerIs = "in"
456465

457466
if self.bDebug == true then
458-
print("SmartSpawn:Start(): Player entered region")
467+
PrintLog("SmartSpawn:Start(): Player entered region")
459468
ShowMessageText("level.common.debug.smartspawn_entered")
460469
end
461470

@@ -471,7 +480,7 @@ function SmartSpawn:Start()
471480
self.playerIs = "out"
472481

473482
if self.bDebug == true then
474-
print("SmartSpawn:Start(): Player exited region")
483+
PrintLog("SmartSpawn:Start(): Player exited region")
475484
ShowMessageText("level.common.debug.smartspawn_exited")
476485
end
477486

@@ -567,13 +576,13 @@ end
567576
function CombatWave:Start()
568577
-- Is the team set? If not, print an error message and exit the function
569578
if self.team == nil then
570-
print("CombatWave:Start(): WARNING: team must be specified! Exiting function")
579+
PrintLog("CombatWave:Start(): WARNING: team must be specified! Exiting function")
571580
return
572581
end
573582

574583
-- Is the spawnPath set? If not, print an error message and exit the function
575584
--[[if self.spawnPath == nil then
576-
print("CombatWave:Start(): WARNING: spawnPath must be specified! Exiting function")
585+
PrintLog("CombatWave:Start(): WARNING: spawnPath must be specified! Exiting function")
577586
return
578587
end]]
579588

@@ -588,10 +597,10 @@ function CombatWave:Start()
588597

589598
-- Spawn the enemies
590599
print()
591-
print("CombatWave:Start(): Spawning "..self.numDudes.." enemies from team "..self.team.." at "..self.container.spawnPath)
600+
PrintLog("CombatWave:Start(): Spawning "..self.numDudes.." enemies from team "..self.team.." at "..self.container.spawnPath)
592601
Ambush(self.container.spawnPath, self.numDudes, self.team)
593602

594-
print("CombatWave:Start(): Total enemiesRemaining:", self.enemiesRemaining)
603+
PrintLog("CombatWave:Start(): Total enemiesRemaining:", self.enemiesRemaining)
595604

596605

597606

@@ -611,7 +620,7 @@ function CombatWave:Start()
611620

612621
-- Decrement enemies remaining
613622
self.enemiesRemaining = self.enemiesRemaining - 1
614-
print("CombatWave:Start(): enemiesRemaining:", self.enemiesRemaining)
623+
PrintLog("CombatWave:Start(): enemiesRemaining:", self.enemiesRemaining)
615624

616625

617626
-- Has spawnValue been met?
@@ -648,7 +657,7 @@ end
648657
-- NOTE: The definition of a "finished wave" is when the spawnValue is met, i.e., the next wave is triggered.
649658
--
650659
function CombatWave:Complete()
651-
print("ME5_CombatManager.CombatWave.Complete(): Exited")
660+
PrintLog("CombatWave.Complete(): Exited")
652661

653662
if self.isComplete then return end
654663

@@ -661,4 +670,4 @@ function CombatWave:Complete()
661670
self:OnComplete()
662671
end
663672

664-
print("ME5_CombatManager: Exited")
673+
PrintLog("Exited")

0 commit comments

Comments
 (0)