Loading a lua file

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
kaypy
Artisan
Posts: 171
Joined: Sun Jan 19, 2014 7:11 am

Loading a lua file

Post 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?
Friends don't let friends eat worm round
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Loading a lua file

Post 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.
kaypy
Artisan
Posts: 171
Joined: Sun Jan 19, 2014 7:11 am

Re: Loading a lua file

Post 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
Friends don't let friends eat worm round
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Loading a lua file

Post 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. :)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Loading a lua file

Post 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.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Loading a lua file

Post by Gambit37 »

Not to worry, I found a note about it in another thread: shortname, filetype, filename.
Post Reply