Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jason1207 |
I have a lot of database regarding monsters, skills, items, quests, npc, etc.
Right now, I have one singleton called LoadData.gd, and all of those database is loaded to that script at the beginning.
However, when I try to access the database via LoadData.gd, the path name comes really long.
This is my skill database script:
class_name Skill_Data
enum {INSIGHT}
var skill_name = {
INSIGHT : "Insight"
}
var skill_res = {
INSIGHT : "res://Skills/Insight.tres"
}
func get_skill_name(a: int):
return skill_name[a]
func get_skill_res(a: int):
return skill_res[a]
this is part of my LoadData.gd:
onready var skill_data = Skill_Data.new()
and on my main scene, to access the above skill, I have as the following:
func _ready():
var insight_skill = load(LoadData.skill_data.get_skill_res(LoadData.skill_data.INSIGHT))
print(LoadData.skill_data.get_skill_name(LoadData.skill_data.INSIGHT))
As you see, the naming becomes way too long and tedious to work with, and I was hoping if I could access the database in a shorter way.
Adding the database itself as another singleton would work, but I’m not sure if that’s the best solution I can go for.
Is there any better ways than doing this?