This is a plugin for Godot 3 to import CastleDB database files as static data in gdscript with autocomplete.
Clone this repository and copy the contents of addons
to your own project's addons
folder.
Enable the plugin in the Project Settings.
Add a CastleDB file somewhere in your project hierarchy. Your CastleDB file must use the .cdb
extension for the importer to generate code.
Add the imported CastleDB file to your AutoLoad scripts in Project Settings.
Enjoy code completion of your static data!
Unique Identifer
, typiclly the column named id
.Unique Identifier
columns.Data.sheetname.get(Data.SheetName.UniqueId)
. This lookup is hashed and fast.all
field and for better autocompletion use the get_index()
function when retreiving a row while iterating. i.e.
for i in Data.sheetname.all.size():
var item = Data.sheetname.get_index(i)
.cdb
file in Godot's script editor. You may need to open the file in an extenral editor from it's imported source in the .import
folder due to limitation of Godot when re-importing / saving your CDB file as the editor seems to cache the original source, however from my experience autocompletion and testing still works without an editor restart.This project is driven entirely by my use of CastleDB in personal projects and is not a complete implementation of all features of CastleDB.
Pull requests welcome!