0 votes

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?

Godot version 3.2.3
in Engine by (24 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.