Godot Version
4.4.1
Question
I’m running a piece of code that takes information from a global dictionary and uses it to assign health, attacks, position etc etc. The code works fine the first time around, but the second time around the input array does not equal the dictionary values from the Global Scene.
I’m unsure as to why this is, because it clearly says in the code
input = Global.enemy_dict[(code)]
Here’s the full relevant code, any help is appreciated:
In the enemy script:
func stat_ecode(code: String): # decodes the input choice from ready function
var input: Array = [] # from global enemy dictionary
input = Global.enemy_dict[(code)]
health = input[0]
fav_pos = input[1]
input.pop_at(0)
input.pop_at(0)
atks = input
func _on_enemy_data(ecode): #chooses the enemy type based on drawn encounter
if data_received == false:
stat_ecode(ecode)
print(health, fav_pos, atks)
data_received = true
else:
print("Complete enemy rereceived data, ignored")
in global scene:
var enemy_dict = { #[health, fav position, atk1, atk2, atk3]
wolf = [15, "front", "bite", "claw"]
}
var enemy_atks = { #[range, hit mod, amt of dmg dice, dice type, dmg mod, status effects]
bite = [1, 1, 1, 6, 0], # DOES NOT ALLOW MULTIPLE DICE TYPES FOR ATTACKS!!!
claw = [1, 1, 1, 4, 1]
}