referencing dictionary with a variable

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cocopioche

export (int) var life
export (String) var ressource
var inventory = Gamemanager.inventorie

func _physics_process(delta: float) → void:

die()

func die():
if life <= 0:
inventory.ressource += 1
queue_free()

it give thir error Invalid get index ‘ressource’ (on base: ‘Node2D (gamemanager.gd)’).

:bust_in_silhouette: Reply From: magicalogic

Your inventory has no attribute ressource so just add it.

I found the answer I needed to do this
inventory[ressource]

cocopioche | 2021-05-21 12:50