Last active
January 3, 2020 16:35
-
-
Save RichardEllicott/92fdc86af74449f5baf6a129aeb14cfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node | |
var inventorys = {} # NEW | |
func _ready(): | |
LoadDictionary("res://Items/Armor/", "Armor") | |
LoadDictionary("res://Items/Consumable/", "Consumables") | |
LoadDictionary("res://Items/Resource/", "Resources") | |
LoadDictionary("res://Items/Weapons/", "Weapons") | |
for i in WeaponsInventory: | |
print("Name: " + WeaponsInventory[i].itemName) | |
print("Damage: " + String(WeaponsInventory[i].minDamage) + " - " + String(WeaponsInventory[i].maxDamage)) | |
func LoadDictionary(myPath, myItemType): | |
var new_array = [] # NEW | |
inventorys[myItemType] = new_array # NEW | |
var dir = Directory.new() | |
var id = 0 | |
dir.open(myPath) | |
dir.list_dir_begin() | |
while true: | |
var file = dir.get_next() | |
# print(myPath + file) | |
if file == "": | |
# If there's no other files to worry about, we break...we're done. | |
break | |
elif file.ends_with(".tscn"): | |
print(myItemType + "Inventory") | |
var itemScene = load(myPath + file).instance() | |
new_array.append(itemScene) # NEW | |
id += 1 | |
dir.list_dir_end() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment