0 votes

For something like const MONSTER: { "shadow": { "sprite: "res://[insert file path], "hp": 20, "atk": 15 }, }

And I want to retrieve it on another script, how can I do it ?

I know that, to retrive a picture, you can assign a variable with, for exemple :
var monster = $"[node path].get_monster("monster_name")"
with a function
func get_monster(monster_id): if monster_id in MONSTER: return MONSTER[monster_id] else: return null

Then you can just load it with load(monster.sprite)

It'll be used to get a monster in the dictionnary, and when it's chosen it'll apply those values in his stats. But I can't figure it out, it keeps saying me that it's not possible in a "Dictionnary"

Hope there is enough info on it

in Engine by (86 points)

1 Answer

0 votes
Best answer


var monster_id = "SHADOW"
var shadow = MONSTER[monster_id]


var hp = int(shadow["hp"])
var atk = int(shadow["atk"])

#do whatever you want with hp and atk vars
by (380 points)
selected by

Thanks a lot ! :3

No problem! Good luck!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.