How to call and load a sprite from a dictionary?

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

Greets!

Got the inside of a backpack to be filled or emptied with items stored in a dictionary. How could i call and load them in the sprite that serve as the inside?

What’s actually in your dictionary that represents the sprite? The sprite’s file name, the sprite’s fully-qualified resource name, the sprite object itself, ???

jgodfrey | 2020-02-17 03:24

There are my two first items:

extends Node2D

var weight = 0
var durability = 0
var protection = 0
var attack = 0
var damage = 0

onready var items = {
	$ClothesArmors/PurClo: {"weight": 3, "durability": 2, "protection": 1},
	$ClothesArmors/LeaBelPoc: {"weight": 0.5, "durability": 1}
}

And these is my scene: Imgur: The magic of the Internet with all the buttons containing the items at body parts, and giving options to exmaine, drop or put in backpack when pressed. A mouse entered gives details about them.

And these is my backpack inside: Imgur: The magic of the Internet Opened when pressed.

What i want is to be able to transfer item from backpack to equiped parts and vice versa, or from the outside world, loading items and their sprite accordingly.

Syl | 2020-02-17 12:24

:bust_in_silhouette: Reply From: code

You can save the sprite locations as a string in the dictionary.

It’s saved (see my coments above with jgodfrey). The tricky part is to call and load them with their sprite.

Syl | 2020-02-17 12:28