Files
idle/currency_generator_database.gd
Michele Rossi bd11d2c037 First commit
2026-03-08 10:38:30 +01:00

32 lines
859 B
GDScript

extends Node
var items: Dictionary = {}
func _ready():
load_item_data()
func load_item_data():
# 1. Open the JSON file
var file = FileAccess.open("res://generator_data.json", FileAccess.READ)
var json_text = file.get_as_text()
# 2. Parse it into a Godot Dictionary
var parsed_data = JSON.parse_string(json_text)
# 3. Loop through and create Custom Resources
for key in parsed_data:
var data = CurrencyGeneratorData.new()
var item_info = parsed_data[key]
# Populate the resource
data.id = key
data.name = key
data.initial_cost = item_info["initial_cost"]
data.coefficient = item_info["coefficient"]
data.initial_time = item_info["initial_time"]
data.initial_revenue = item_info["initial_revenue"]
data.initial_productivity = item_info["initial_productivity"]
# Store it in our database dictionary
items[key] = data