First commit
This commit is contained in:
31
currency_generator_database.gd
Normal file
31
currency_generator_database.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
Reference in New Issue
Block a user