Page 1 of 1

Loading a lua file

Posted: Tue Jan 28, 2014 3:06 pm
by kaypy
I am currently attempting to separate some configuration off of the dungeon.lua and into a file of its own. The problem is that I am somewhat stymied in loading in said file.

I can get it to load via dsb_import_arch, but that can only be done in the objects.lua, which means it doesn't show up in dungeon.lua and thus breaks ESB.

I can get it to load via lua_manifest in startup.lua, but again that breaks ESB.

I can't get dsb_include_file to work anywhere.

I could use the lua built in loadfile, but requires the path to the file relative to the DSB executable, which could be different on other people's installations. I don't seem to have any way to get that path from the script.

Is there something I am missing here?

Re: Loading a lua file

Posted: Tue Jan 28, 2014 10:47 pm
by Sophia
ESB only loads startup.lua and ignores the lua_manifest.

The reason it does this is because DSB existed long before ESB; when I was writing ESB, I realized what a terrible mess it would be to try to get ESB to parse all of the configuration files. So, it only parses the root files, and ignores the manifest. This generally works, but can create problems in certain cases, as you've observed.

Anyway, no matter what, you shouldn't be putting configuration into dungeon.lua. If you're using ESB, you probably shouldn't be hand-editing dungeon.lua at all, because ESB will rewrite the file every time you save without any regard for what was in there before.

My initial suggestion is to just put your configuration stuff in startup.lua. I don't know how much bloat this would create or whether this would be inconvenient, but it's an option. If this won't work for some reason, we can figure something else out.

Oh, as an aside, dsb_include_file is for telling DSB to include a certain file in graphics.dsb when compiling and has nothing to do with this.

Re: Loading a lua file

Posted: Wed Jan 29, 2014 2:19 am
by kaypy
Thanks

It's not a big deal if I can't put it in a separate file. I just didn't want to have there be an easy way to do it which I missed because I didn't know my way around the system enough.

I've been playing around with modifications to Chaos Hack, so all my editing is by necessity hand-coded, but I wanted the 'load it in ESB to get a permanent dungeon' trick to work (And as things stand it does, but you have to go into the big lua files to configure stuff, rather than tweaking a 'this file is config and only config' file)
dsb_include_file is for telling DSB to include a certain file in graphics.dsb when compiling
Hmm. Is that just for the base data or could a custom dungeon have it's own batched graphics file? Not that I really need to know but since I have some new info I figure I should update the wiki.

Edit: the main program has graphics.dat not graphics.dsb and the wiki mentions loading from graphics.dsb before graphics.dat so I'm guessing this is for compiling custom dungeons and not base data

Re: Loading a lua file

Posted: Wed Jan 29, 2014 5:49 am
by Sophia
Well, there's no easy way right now, but if it becomes a needed feature, feel free to request something and I'll see what I can do.
Anyway, you are correct. A custom dungeon's graphics file is graphics.dsb.

If you do end up adding to the wiki, thank you! It needs all the help it can get. :)

Re: Loading a lua file

Posted: Thu Dec 20, 2018 9:27 am
by Gambit37
What are the parameters for dsb_include_file()? Looks like it expects 2 or 3, but I can only guess at one, the filename.

Re: Loading a lua file

Posted: Thu Dec 20, 2018 10:13 am
by Gambit37
Not to worry, I found a note about it in another thread: shortname, filetype, filename.