Skip to content

Commit

Permalink
Replace for _, with for idx, to prevent localization issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
daid committed Jun 17, 2024
1 parent 34043fe commit aa05416
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 87 deletions.
4 changes: 2 additions & 2 deletions scripts/scenario_03_waves.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ function update(delta)
-- Count enemies and friends
local enemy_count = 0
local friendly_count = 0
for _, enemy in ipairs(enemyList) do
for idx, enemy in ipairs(enemyList) do
if enemy:isValid() then
enemy_count = enemy_count + 1
end
end
for _, friendly in ipairs(friendlyList) do
for idx, friendly in ipairs(friendlyList) do
if friendly:isValid() then
friendly_count = friendly_count + 1
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/scenario_05_beacon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function missionGotoTransport(delta)
Target its impulse engines with your beam weapons to halt its progress.]])
)

for _, transport in ipairs(transports) do
for idx, transport in ipairs(transports) do
transport:orderDock(research_station)
end

Expand Down
14 changes: 7 additions & 7 deletions scripts/scenario_08_atlantis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function init()
player:setPosition(25276, 133850):setCallSign("Atlantis-1"):setRotation(-90):commandTargetRotation(-90)

-- Set all systems to 0 power.
for _, system in ipairs(
for idx, system in ipairs(
{
"reactor",
"beamweapons",
Expand Down Expand Up @@ -298,7 +298,7 @@ Doppler instability: %i]]),
--[[TEMP
mission_state = phase2SeekArtifact
player:setPosition(310000, -71000)
for _, system in ipairs({"reactor", "beamweapons", "missilesystem", "maneuver", "impulse", "warp", "jumpdrive", "frontshield", "rearshield"}) do
for idx, system in ipairs({"reactor", "beamweapons", "missilesystem", "maneuver", "impulse", "warp", "jumpdrive", "frontshield", "rearshield"}) do
player:setSystemPower(system, 1.0)
player:commandSetSystemPowerRequest(system, 1.0)
end
Expand Down Expand Up @@ -330,7 +330,7 @@ First, have your engineer power up all systems to 100%, as you are currently in
end

function phase1WaitForPowerup(delta)
for _, system in ipairs({"reactor", "beamweapons", "missilesystem", "maneuver", "impulse", "frontshield", "rearshield"}) do
for idx, system in ipairs({"reactor", "beamweapons", "missilesystem", "maneuver", "impulse", "frontshield", "rearshield"}) do
if player:getSystemPower(system) < 1.0 then
return
end
Expand Down Expand Up @@ -620,7 +620,7 @@ function phase4JumpBackToShipyard(delta)
Dock with us and we'll take a shot at cracking them.]])
)
-- Remove all Kraylor ships attacking the player from the game. We no longer need them, and they could mess things up if they get the time to fly all the way to the shipyard.
for _, ship in ipairs(kraylor_defense_line_ships) do
for idx, ship in ipairs(kraylor_defense_line_ships) do
if ship:isValid() then
ship:destroy()
end
Expand Down Expand Up @@ -952,7 +952,7 @@ end

function putKraylorDefenseLineOnFullOffense()
if not kraylor_defense_line_engaged then
for _, ship in ipairs(kraylor_defense_line_ships) do
for idx, ship in ipairs(kraylor_defense_line_ships) do
if ship:isValid() then
ship:orderAttack(player)
end
Expand All @@ -976,15 +976,15 @@ function update(delta)
end

-- If the player enters the Kraylor defense line, or engages a forward station, attack with all forces.
for _, warp_jammer in ipairs(kraylor_defense_line) do
for idx, warp_jammer in ipairs(kraylor_defense_line) do
if warp_jammer ~= nil and warp_jammer:isValid() then
if distance(player, warp_jammer) < 6000 then
putKraylorDefenseLineOnFullOffense()
end
end
end

for _, station in ipairs(kraylor_forward_line) do
for idx, station in ipairs(kraylor_forward_line) do
if station ~= nil and station:isValid() then
if distance(player, station) < 3000 then
putKraylorDefenseLineOnFullOffense()
Expand Down
6 changes: 3 additions & 3 deletions scripts/scenario_10_empty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ function init()
_("buttonGM", "Delete unselected"),
function()
local gm_selection = getGMSelection()
for _, obj in ipairs(getAllObjects()) do
for idx, obj in ipairs(getAllObjects()) do
local found = false
for _, obj2 in ipairs(gm_selection) do
for idx2, obj2 in ipairs(gm_selection) do
if obj == obj2 then
found = true
end
Expand All @@ -67,7 +67,7 @@ end
function cleanup()
-- Clean up the current play field. Find all objects and destroy everything that is not a player.
-- If it is a player, position him in the center of the scenario.
for _, obj in ipairs(getAllObjects()) do
for idx, obj in ipairs(getAllObjects()) do
if obj.typeName == "PlayerSpaceship" then
obj:setPosition(random(-100, 100), random(-100, 100))
else
Expand Down
6 changes: 3 additions & 3 deletions scripts/scenario_30_brokenglass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function init()
SpaceStation():setTemplate("Medium Station"):setFaction("Human Navy"):setCallSign("SE Checkpoint"):onTakingDamage(CommsBeingAttacked):setPosition(73035, 26331):setRepairDocked(true):setRestocksScanProbes(true):setSharesEnergyWithDocked(true),
SpaceStation():setTemplate("Medium Station"):setFaction("Human Navy"):setCallSign("NE Checkpoint"):onTakingDamage(CommsBeingAttacked):setPosition(75919, -30678):setRepairDocked(true):setRestocksScanProbes(true):setSharesEnergyWithDocked(true)
}
for _, stn in ipairs(Patrol_stations) do
for idx, stn in ipairs(Patrol_stations) do
stn:setCommsFunction(CommsPatrolStation)
end

Expand Down Expand Up @@ -372,7 +372,7 @@ function init()
self:setCallSign("")
local x, y = self:getPosition()
local defenders = SpawnEnemies(x + irandom(-5000, 5000), y + irandom(-5000, 5000), random(.6,1), "Ghosts")
for _, ship in ipairs(defenders) do
for idx, ship in ipairs(defenders) do
table.insert(Defence_station.ghost_defenders, ship)
end
Player:addToShipLog(_("nebulaBonuses-shipLog", "We have activated a drone defence system!"),"Red")
Expand Down Expand Up @@ -859,7 +859,7 @@ end
function InitDroneStations()
Defence_station.drones_think_were_friendly = false
Defence_station.convoy_enemies = {}
for _, stn in ipairs(Drone_stations) do
for idx, stn in ipairs(Drone_stations) do
stn.spawns_left = 5
stn:setCanBeDestroyed(false)
stn:onTakingDamage(DroneStationGoAggro)
Expand Down
8 changes: 4 additions & 4 deletions scripts/scenario_55_defenderHunter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ function GMSpawnsEnemies()
-- Let the GM spawn a random group of enemies to attack a player
local gmPlayer = nil
local gmSelect = getGMSelection()
for _, obj in ipairs(gmSelect) do
for idx, obj in ipairs(gmSelect) do
if obj.typeName == "PlayerSpaceship" then
gmPlayer = obj
break
Expand All @@ -483,7 +483,7 @@ function GMSpawnsEnemies()
local px, py = gmPlayer:getPosition()
local sx, sy = vectorFromAngle(random(0,360),random(20000,30000))
ntf = spawnEnemies(px+sx,py+sy,dangerValue,targetEnemyStation:getFaction())
for _, enemy in ipairs(ntf) do
for idx, enemy in ipairs(ntf) do
enemy:orderAttack(gmPlayer)
end
end
Expand Down Expand Up @@ -10464,7 +10464,7 @@ function endStatistics()
survivedFriendlyStations = 0
destroyedNeutralStations = 0
survivedNeutralStations = 0
for _, station in pairs(originalStationList) do
for idx, station in pairs(originalStationList) do
tp = getPlayerShip(-1)
if tp ~= nil and tp:isValid() then
if station:isFriendly(tp) then
Expand All @@ -10484,7 +10484,7 @@ function endStatistics()
destroyedFriendlyStations = startingFriendlyStations - survivedFriendlyStations
destroyedNeutralStations = startingNeutralStations - survivedNeutralStations
enemyStationsSurvived = 0
for _, station in pairs(enemyStationList) do
for idx, station in pairs(enemyStationList) do
if station:isValid() then
enemyStationsSurvived = enemyStationsSurvived + 1
end
Expand Down
4 changes: 2 additions & 2 deletions scripts/scenario_56_carrierTurret.lua
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function GMSpawnsEnemies()
gmPlayer = nil
gmSelected = false
gmSelect = getGMSelection()
for _, obj in ipairs(gmSelect) do
for idx, obj in ipairs(gmSelect) do
if obj.typeName == "PlayerSpaceship" then
gmPlayer = obj
break
Expand All @@ -335,7 +335,7 @@ function GMSpawnsEnemies()
px, py = gmPlayer:getPosition()
sx, sy = vectorFromAngle(random(0,360),random(20000,30000))
ntf = spawnEnemies(px+sx,py+sy,dangerValue,targetEnemyStation:getFaction())
for _, enemy in ipairs(ntf) do
for idx, enemy in ipairs(ntf) do
enemy:orderAttack(gmPlayer)
end
end
Expand Down
4 changes: 2 additions & 2 deletions scripts/scenario_81_pvp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,13 @@ With the Kraylor flagship out of the way, we can land the final blow!]])
-- Count transports. Every 10 seconds, award 1 point per transport docked
-- with Shangri-La.
if troop_timer > 10 then
for _, transport in ipairs(troops_kraylor) do
for idx, transport in ipairs(troops_kraylor) do
if transport:isValid() and transport:isDocked(shangri_la) then
points_kraylor = points_kraylor + 1
end
end

for _, transport in ipairs(troops_human) do
for idx, transport in ipairs(troops_human) do
if transport:isValid() and transport:isDocked(shangri_la) then
points_human = points_human + 1
end
Expand Down
Loading

0 comments on commit aa05416

Please sign in to comment.