I am trying right now to import my castledb fileand pass it into cdb.Module.build which takes a string. How do I do that? My Autocomplete is not showing me options in KodeStudio (likely because I'm trying to convert my whole RTSBase Project at once), so I can't find it using a process of elimination. Should it be in Assets.blobs?
-
importing a text asset (castle .cdb json file) to get string
Awesome, that worked. I had to comment out the root class of my code to try it, but it works. Unfortunately, it seems that CastleDB isn't setup to handle the way Kha loads assets.
I've tried this:
private typedef Init = haxe.macro.MacroType < [cdb.Module.build(Assets.blobs.database_cdb.toString())] > ;
and I get
..\Sources/systems/Data.hx:10: characters 64-100 : { pos : haxe.macro.Position, expr : haxe.macro.ExprDef } should be String
I looked at my Haxeflixel project, and found that i was just passing the location of the file as a string. attempting to do that gives me:
..\Sources/systems/Data.hx:10: characters 8-22 : File not found Assets/data/database.cdbI tried looking into cdb.Module.build, but its a very deep function. Do any of the error messages sound like something that you've seen and have an idea about, or is this more of a CastleDB issue?
-
importing a text asset (castle .cdb json file) to get string
Don't have any experience with castledb, but had a quick look at the website...
The thing is, with Kha you usually don't use Haxe's regular file apis to load files as the Assets class provides a more portable alternative. It should still work though but you have to make sure your file actually ends up in your deployment folder (build/systemname) and you use the path in there (probably just database.cdb).
The macro thing tries to load the file at compile time so that's unrelated to Kha's asset handling and I think the correct line would be haxe.macro.MacroType<[cdb.Module.build("../Assets/data/database.cdb")]>; (notice the ../ because Kha creates all build files inside the build subdirectory by default). -
importing a text asset (castle .cdb json file) to get string
That worked! I no longer get the error! It'll be a while before I have things working well enough to see if I'm out of the woods but I definately have a better understanding of what is going on now.
Thank you so much for your help, I'm way excited to get this rewrite going, and to start leveraging Kha!