Editing and Customization > Community Content
GES Python Library now on GitHub!
killermonkey:
I settled with this compromise solution, it looks great in game too:
--- Code: ---
def PrintWeapons( self, player ):
# Player's at the max level don't see this message
if not player:
return
curr_level = self.GetLevel( player )
if curr_level == maxLevel:
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", "You are on the final level!" )
return
# Start with the player's current level
arWeapons = "Current Level %i: #%s\n\n" % ( curr_level + 1, GEWeapon.WeaponPrintName( weaponList[curr_level][0] ) )
# Output up to the next 4 weapons for this player, not including the final weapon
count = 0
for i in range( curr_level + 1, maxLevel ):
count += 1
arWeapons += "Level %i: #%s\n" % ( i + 1, GEWeapon.WeaponPrintName( weaponList[i][0] ) )
if count == 4:
break
# Tack on the final weapon
arWeapons += "\nFinal Level %i: #%s\n" % ( len( weaponList ), GEWeapon.WeaponPrintName( weaponList[-1][0] ) )
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", arWeapons )
--- End code ---
Troy:
That looks pretty damn good from the code.
Troy:
I've tested your code. In my opinion, some adjustments need to be made. We can't have a double line break after the current level. The reason being is this:
I think it's best to make Current Level x and Final Level x a lower case l. Also, I don't think a double line break needed if there isn't a gap between the levels. Lastly, you forgot a return statement for when the player wins.
--- Code: ---
def PrintWeapons( self, player ):
if not player:
return
lvl = self.GetLevel( player )
if lvl > maxLevel:
return
if lvl < maxLevel:
# Start with the player's current level
arWeapons = "Current level %i: #%s\n" % ( lvl + 1, GEWeapon.WeaponPrintName( weaponList[lvl][0] ) )
# Output up to the next 4 weapons excluding the final weapon
count = 0
for i in range( lvl + 1, maxLevel ):
count += 1
arWeapons += "Level %i: #%s\n" % ( i + 1, GEWeapon.WeaponPrintName( weaponList[i][0] ) )
if count == 4:
break
# Tack on the final weapon
if lvl + 5 < maxLevel:
arWeapons += "\nFinal level %i: #%s\n" % ( len( weaponList ), GEWeapon.WeaponPrintName( weaponList[-1][0] ) )
else:
arWeapons += "Final level %i: #%s\n" % ( len( weaponList ), GEWeapon.WeaponPrintName( weaponList[-1][0] ) )
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", arWeapons )
else:
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", "You are on the final level!" )
--- End code ---
Gapped
Not Gapped
Navigation
[0] Message Index
[*] Previous page
Go to full version