Refactor HedgeEditor output, get rid of wepArray in favor of simpler ammo iteration
authorWuzzy <almikes@aol.com>
Thu, 27 Apr 2017 04:44:55 +0200
changeset 12360 37ed9df448fa
parent 12359 5e4ac10a03ce
child 12361 d1448cc0b8c2
Refactor HedgeEditor output, get rid of wepArray in favor of simpler ammo iteration
share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Thu Apr 27 03:38:22 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Thu Apr 27 04:44:55 2017 +0200
@@ -1962,21 +1962,6 @@
 	WriteLnToConsole("local hhs = {}")
 	WriteLnToConsole("")
 
-	WriteLnToConsole("local wepArray = {")
-	WriteLnToConsole("		amBazooka, amBee, amMortar, amDrill, amSnowball,")
-	WriteLnToConsole("		amGrenade, amClusterBomb, amMolotov, amWatermelon, amHellishBomb, amGasBomb,")
-	WriteLnToConsole("		amShotgun, amDEagle, amSniperRifle, amSineGun, amLandGun, amIceGun,")
-	WriteLnToConsole("		amFirePunch, amWhip, amBaseballBat, amKamikaze, amSeduction, amHammer,")
-	WriteLnToConsole("		amMine, amDynamite, amCake, amBallgun, amRCPlane, amSMine, amAirMine,")
-	WriteLnToConsole("		amAirAttack, amMineStrike, amDrillStrike, amNapalm, amPiano, amBirdy,")
-	WriteLnToConsole("		amBlowTorch, amPickHammer, amGirder, amRubber, amPortalGun,")
-	WriteLnToConsole("		amRope, amParachute, amTeleport, amJetpack,")
-	WriteLnToConsole("		amInvulnerable, amLaserSight, amVampiric,")
-	WriteLnToConsole("		amLowGravity, amExtraDamage, amExtraTime, amResurrector, amTardis, amSwitch")
-	WriteLnToConsole("	}")
-	WriteLnToConsole("")
-
-
 	SaveConfigData()
 
 
@@ -2342,8 +2327,10 @@
 	WriteLnToConsole("function onAmmoStoreInit()")
 	WriteLnToConsole("")
 
-	WriteLnToConsole("	for i = 1, #wepArray do")
-	WriteLnToConsole("		SetAmmo(wepArray[i], 0, 0, 0, 1)")
+	WriteLnToConsole("	for i = 0, AmmoTypeMax do")
+	WriteLnToConsole("		if i ~= amNothing then")
+	WriteLnToConsole("			SetAmmo(i, 0, 0, 0, 1)")
+	WriteLnToConsole("		end")
 	WriteLnToConsole("	end")
 	WriteLnToConsole("")
 	WriteLnToConsole("	SetAmmo(amSkip, 9, 0, 0, 0)")