Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | potatobanana |
what i want to do is, when all value in GlobalDta.skill_list["test_cd"][x].c_cd
become 0
timer will stop, then i can check if all GlobalDta.skill_list["test_cd"][x].c_cd
<=0
then i get true.
but after i get this result it stop decreasing.
one more thing,why when i make GlobalDta.skill_list["test_cd"][x].c_cd
to var cd_list = GlobalDta.skill_list["test_cd"][x].c_cd
then continue like this cd_list -=1
it wont work. it just decrease once then stop decreasing.
how should i make work? and why it happen?
func _on_Timer_timeout() -> void:
for x in GlobalDta.skill_list["test_cd"].keys():
if GlobalDta.skill_list["test_cd"][x].c_cd >0:
GlobalDta.skill_list["test_cd"][x].c_cd -=1
print(GlobalDta.skill_list["test_cd"][x].c_cd)
else:
$Timer.stop()
print("done")
result
0
0
4
2
done
done
3
1
json dict
{
"test_cd": {
"skill1": {
"name": "fire",
"c_cd": 1,
"max_cd": 3.5
},
"skill2": {
"name": "water",
"c_cd": 1,
"max_cd": 10
},
"skill3": {
"name": "wind",
"c_cd": 5,
"max_cd": 5
},
"skill4": {
"name": "earth",
"c_cd": 3,
"max_cd": 6.5
}
}
}