When following your code, I see that wpn_name
is a temporary variable. Its keys are weapon IDs and values are, I assume, integers representing the energy of the weapon (which you obtain using some sort of player ID?).
Next you determine what is the ID of the weapon.
Finally, you increase the number within wpn_name
corresponding to that weapon ID.
However, remember, wpn_name
is a temporary variable. And what's inside the dictionary are integers which you had previously copied. Integers are not references, so globals don't get updated.
You need to copy the value back to the global dictionary if you want it to persist.
Another way though, is to not get the value, but the container holding it. Containers are references (Array and Dictionary), so modifying one will be equivalent to modify the global:
if wpn_en > 0 and heal_delay == 1:
var player_swap = int($player.swap)
var wpn_name = {
1 : global.rp_coil,
2 : global.rp_jet,
3 : global.weapon1,
4 : global.weapon2,
5 : global.weapon3,
6 : global.weapon4,
7 : global.weapon5,
8 : global.weapon6,
9 : global.weapon7,
10 : global.weapon8,
11 : global.beat,
12 : global.tango,
13 : global.reggae
}
if global.player_weap[player_swap] > 0 and global.player_weap[player_swap] < 11:
id = global.player_weap[player_swap]
else:
id = global.player_weap[player_swap] + global.player
wpn_name[id][player_swap + 1] += 10
wpn_en -= 10
(I didn't test this code, you'll need to figure out if I'm right with the rest of the code)