-1
well, I made a "minigame" with even a save/load system. the problem is that after saving or loading the game, ask to "mine", the script returns me the except command of the first command.
guy:
i save, load, save. when I "mine" it shows except save first, if I mine dnv, it shows the except of "load", dnv dai it shows the except of the "save".
i.e., shows except of commands in sequence, even if the function is not called.
this happened dps I try to implement a value to mine, like mine 3 at a time or 5. the "Minepower"
print('"jogo" ainda em desenvolvimento, relatar qualquer bug ao desenvolvedor\n')
tier1=0
tier2=0
MinePower=1
def setup(tier1, tier2,MinePower):
tier1=int(tier1)
tier2=int(tier2)
print("--------------------------------------")
print("| Melhorar Minerar Salvar |")
print("| Carregar Inventario |")
print("--------------------------------------")
acao=input()
if acao=='melhorar' or acao=='Melhorar':
if tier1>=9:
tier1=tier1-9
tier2+=1
print('\nVocê comprimiu suas pedras, agora você tem',tier2,'Pedras Tier 2 e',tier1,'Pedras Tier 1.' )
setup(tier1, tier2, MinePower)
else:
print("\nVocê não tem pedras suficientes.")
setup(tier1, tier2, MinePower)
elif acao=='minerar' or acao=='Minerar':
tier1=tier1+MinePower
print("\nVocê minerou",MinePower,"Pedra, agora você tem",tier1,"Pedras.")
setup(tier1,tier2,MinePower)
elif acao=='salvar' or acao=='Salvar':
save(tier1,tier2,MinePower)
elif acao=='carregar' or acao=='Carregar':
carregar(tier1,tier2,MinePower)
elif acao=='Inventario' or acao=='inventario':
print("Pedras:",tier1)
print("Pedras Comprimidas:",tier2)
setup(tier1, tier2, MinePower)
else:
print("-=-=-=-=-=-=-=Comando desconhecido=-=-=-=-=-=-=-")
setup(tier1,tier2,MinePower)
setup(tier1,tier2,MinePower)
def save(SaveTier1,SaveTier2,SaveMinePower):
try:
SaveFile=open("Save.txt","w")
SaveFile.write(str(SaveTier1)+'\n'+str(SaveTier2)+'\n'+str(SaveMinePower))
print('Um Save nomeado "Save" foi criado')
SaveFile.close()
setup(SaveTier1,SaveTier2,SaveMinePower)
except:
print("Erro ao salvar arquivo")
setup(SaveTier1,SaveTier2,SaveMinePower)
setup(SaveTier1,SaveTier2,SaveMinePower)
def carregar(BackupT1,BackupT2,BCMinePower):
try:
CarrFile=open("Save.txt","r")
CarrTier1=CarrFile.readline()
CarrTier2=CarrFile.readline()
CarrMinePower=CarrFile.readline()
CarrFile.close()
setup(CarrTier1,CarrTier2,CarrMinePower)
except:
print("Erro ao carregar arquivo, seu caminho ou nome podem ter sido modificados.")
setup(BackupT1, BackupT2, BCMinePower)
setup(BackupT1,BackupT2,BCMinePower)
setup(tier1,tier2,MinePower)
The setup() function is being called twice.
– tomasantunes
but the except being called n is in setup
– Um Canal Qualquer
In each function you call the
setup
three times. That’s right? You call inside thetry
, within theexcept
and then off the blocktry/catch
, which implies that the functionsetup
will be executed at least twice each call of one of the functions. This doesn’t seem to make sense.– Woss