So I’m trying to use a list to set the order of towers I upgrade however im experiencing this issue any idea to fix
order=["a","b","e","f","g","h","c","d"]
tick=1
#Functions
def upgrade():
point=order[tick]
towerLV=hero.getTowerAt(point).level
towerType=hero.getTowerAt(point).type
if hero.mana > (towerLV*10)+hero.time:
hero.build(towerType,point)
if tick >= 7:
tick = 0
else:
tick += 1
More specifically the thing gives me the error that the input must be a letter
Frozen Fortress the tower defence
k, while I try to find the issue, maybe you could try using my code snippet from tips and tricks?
also btw why the +hero.time
Um that would require me to manually do this snippet for each individual tower
not to mention the editor breaks when the argument is anything but a string
wait no this is a different arena one sec
well in my head it was to limit the mana spending as the fight went on
wait it’s the same arena I’m confusedd
??? sorry im new to this forum
k, also, here, new code:
order=["a","b","e","f","g","h","c","d"]
tick=1
#Functions
def upgrade(t):
point=order[t]
towerLV=hero.getTowerAt(point).level
towerType=hero.getTowerAt(point).type
if hero.mana > towerLV * 10 + hero.time:
hero.build(towerType,point)
if t >= 7:
return 0
else:
return t + 1
while True:
tick = upgrade(tick)
python is a bit weird with variables so I needed to add an argument to the function instead of using tick
directly, and now instead of modifying it in the function (which doesn’t actually modify it btw), you modify it outside by tick = upgrade(tick)
, so whenever you need to call the function you must do tick = upgrade(tick)
unless you want tick to be unchanged