Compiling Lua files?

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

Compiling Lua files?

Post by Gambit37 »

I tried using LuaC to compile my Lua files -- it created one file called luac.out that seemed buggy (it couldn't find some item references). I guess this is due to the order that things are added into the single compiled file?

Do I need to compile each file separately? If so, how should the compiled files be named?

Any other considerations (particularly regarding dependencies - files that call other files using dsb_import_arch() )

Also, related: what gets saved in a compiled graphics.dsb -- does it include sounds and music too?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

Yes, it has to do with order. In particular, objects.lua must remain a separate file because it's executed at a different time than the others. This should solve your issues, but if all else fails, compiling all files separately will also work. Importable archetypes should be their own files too, or things will go horribly wrong.

I couldn't find an "official" extension for compiled Lua, so DSB uses .lxx for compiled Lua. When you attempt to load a piece of Lua script, DSB will search first for .lua source code. If it can't find that, it will then try to load a .lxx compiled file. If it can't find either, it will throw an error. So, if your lua_manifest names "example.lua" then DSB will first try to load example.lua and then example.lxx.
Gambit37 wrote:what gets saved in a compiled graphics.dsb
A compiled graphics.dsb saves graphics and sounds. It does not save music invoked via dsb_music, because that's streamed from disk and is likely a large file. You can force inclusion of files via dsb_include(short_name, file_type, long_name), though. (e.g., dsb_include("MUSIC", "mp3", "music.mp3") )
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

OK, thanks. I can't get this to work though. I compiled all the Lua files to lxx files. I also have my compiled graphics.dsb and dungeon.dsb. DSB crashes after the blue screen startup complaining that it "can't find startup.lua"...?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

Can you paste me your log.txt?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Code: Select all

INIT: Parsing configuration file
INIT: Using gamedir E:\Dungeon Master\Custom Games (Me)\SNP\_dsb49\luac (base:0)
INIT: Starting windowed mode
INIT: Using color depth of 32
INIT: Starting FMOD
INIT: Triple buffering unavailable or disabled.
LUA: Lua initialized
Parsing base/global.lua
Parsing base/graphics.lua
Parsing base/inventory_info.lua
Parsing base/util.lua
Parsing base/triggers.lua
Parsing base/conditions.lua
Parsing base/monster.lua
Parsing base/monster_ai.lua
Parsing base/methods.lua
Parsing base/damage.lua
Parsing base/xp.lua
Parsing base/magic.lua
Parsing base/msg_handlers.lua
Parsing base/hooks.lua
Parsing base/system.lua
Parsing base/render.lua
Parsing base/startup.lua
FATAL LUA ERROR: File not found: E:\Dungeon Master\Custom Games (Me)\SNP\_dsb49\luac/startup.lua
@@@ LUA STACK @@@
[{@_G}][{ resume yield status wrap create running }][{ sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower }][{ setn insert getn foreachi maxn foreach concat sort remove }][{ log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan }][{ __index __gc }][S:E:\Dungeon Master\Custom Games (Me)\SNP\_dsb49\luac/startup.lxx: bad header in precompiled chunk]
@@@@@@
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

Hmm, it says "bad header in precompiled chunk."
According to that, it means you're trying to run code that was compiled on a different architecture.

Are you using a 64-bit OS? DSB is a 32-bit program, so you'll probably need to compile as 32-bit.
What parameters did you pass to LuaC?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Aha! That sounds like the prob -- I have 64bit Win 7 and downloaded the 64 bit Lua compiler. I'll try it with the 32-bit version and report back.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

OK, compiling in 32bit gets further. But now it generates the same error, but for "graphics.lua" -- surely it shouldn't be looking for that, since I compiled it into graphics.dsb instead?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

I think I know what the problem is.

You compiled everything into a single file, right? Nobody's ever done that before; I always made separate files. I didn't realize LuaC even did that. Anyway, what it's probably doing is trying to load lua_manifest, which won't work because it's all shoved into a single file now. What I don't know is if any code that depends on being parsed in a certain order (which lua_manifest lets you do) is going to still work. Maybe it parses the code in the order that you specify the files-- that's how I'd do it, anyway.

To fix this, I'll add an option to tell DSB to disregard the lua_manifest when running startup.lxx.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

No, I compiled them all into separate .LXX files. But your diagnosis would still seem to be correct -- it's trying to load files in lua_manifest.

I created a handy Windows 7 batchfile to compile all the files (Put the Lua compiler and DLLs in Windows directory):

Code: Select all

forfiles /m *.lua /c "cmd /c luac5.1 -o @fname.lxx @file"
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

Well that's odd.
Can I see log.txt again?

Also can you explain what you meant by "compiled it into graphics.dsb instead," you might be confused; you still need graphics.lua even if you're using a compiled graphics file.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Argh, duhhhhhhhhhhhhh. Right! Let me try again... (I thought they were the same!). Will be next week as I'm away now for weekend. Thanks for all your help this week :-)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

I am trying to compile a graphics.dsb so I can send you my buggy dungeon, Sophia, but I can't seem to get it to work.

I've set my startup file to look in these paths for my assets:

Code: Select all

-- Folder paths
pathroot = "./"
pathimg = "_img/"
pathsfx = "_sfx/"
pathmus = "_mus/"
Then in my graphics.lua, I append subfolders to these paths, when I want to change the place DSB is looking for assets, for example:

Code: Select all

-- Rocky Walls, Grey & Green Moss
path = pathimg .. "walls/rock2/"
gfx.wall_rock2_floor = dsb_get_bitmap(path .. "rock2-floor")
gfx.wall_rock2_roof = dsb_get_bitmap(path .. "rock2-roof")
...
I then compiled a graphics.dsb and dungeon dsb, and copied those and all my uncompiled Lua files into a fresh folder to test it out as a "stand alone" package.
This does not work - DSB complains that it can't find any images, and cites the full relative path it's currently looking in as the problem.
I thought when you used a graphics.dsb, it would look in there first, rather than the file names / paths specified in the Lua files?
I'm confused about how to solve this....?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

I'm actually a bit confused as to what could be going wrong here.

To be completely pedantic, you've used the syntax wrong. The usual way of using dsb_get_bitmap with a full path is by specifying a short name (that gets compiled) and then a long path, such as something like:

Code: Select all

dsb_get_bitmap("UGLY_MONSTER_FRONT", "images/monsters/ugly_monster_front.png")
However, to save you a lot of typing to convert the stuff you've already written-- the truth is, the way you're doing it should actually work, because I've seen other people doing exactly that. It's not ideal, because it stores the file with its whole long name, slashes and all, as its name in graphics.dsb, which is kind of weird. People have actually done this and it worked fine, though. I've never seen this actually create a problem before.

It might be something weird with extensions. Try changing pathroot to just an empty string (and removing any other dots that aren't extensions) and see how that works for you.

If that doesn't work, I'll try adding an option to automatically generate a short name for graphics.dsb if you've used a path like the one there... because I'm not sure what the problem would be, except that the names are long.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Ok, I tried something out, and am more confused!

In development mode (uncompiled), this code works fine, and clearly loads the files from their disk path:

Code: Select all

path = "_img/title/"
gfx.intro_credits1 = dsb_get_bitmap(path .. "intro-credits1")
If I then compile the file, and copy the *.DSB and *.LUA to a clean folder, that code no longer works. DSB complains with this error:

Code: Select all

Bitmap not found: _img/title/intro-credits1
So I edited the code in the clean stand-alone folder and changed it to read:

Code: Select all

path = "_img/title/"
gfx.intro_credits1 = dsb_get_bitmap("intro-credits1", path .. "intro-credits1")
That also doesn't work, and generates this error:

Code: Select all

Bitmap not found: intro-credits1 (_img/title/intro-credits1)
So the final test was to add the .png extension:

Code: Select all

path = "_img/title/"
gfx.intro_credits1 = dsb_get_bitmap("intro-credits1", path .. "intro-credits1.png")
No good, I get this error:

Code: Select all

Bitmap not found: intro-credits1 (_img/title/intro-credits1.png)
HOWEVER.... if I recompile the files with those third changes (shortname + fullpath) and copy the recompiled *.DSB to the cleaned folder -- then I don't get an error.

So it looks like I have to specify both a shortname AND the full path with file extension....

Interestingly, if I compile with this code

Code: Select all

gfx.intro_credits1 = dsb_get_bitmap("intro-credits1", path .. "intro-credits1.png")
and then edit the LUA file in the standalone folder to be this code

Code: Select all

gfx.intro_credits1 = dsb_get_bitmap("intro-credits1", path .. "intro-credits1")
...it still works, and there are no errors.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

As it turns out, DSB doesn't like the slashes.
I'm sure this worked before, but maybe the other users never actually tried loading directly from graphics.dsb or something.

Anyway, the short (and hopefully good) answer is: I can fix this. :D
Any graphics.dsb compiled before this fix won't work, but that's not too hard to remedy.

As an aside, the reason why this doesn't work:

Code: Select all

dsb_get_bitmap("SHORTNAME", "path/to/longname")
... is that if you're specifying a long file name, you need to specify the extension. However, once DSB has made a graphics.dsb, it only uses the short names when loading from there, so you can edit the longname to be anything you want and it won't even use it.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Weird that it works during dev, but not after it's compiled? Anyway, great, hope you can fix it.
Going forward, does this mean I don't need to change my code and can use those paths without a short name?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

It's not weird to me... but then again, I wrote it. I'm probably just used to it. :P

And yes, you won't need to change anything.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Coolio :-)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

So I just did a test compile for the first time in ages and some stuff is broken:

* champion portraits don't load in my champion selector
* the wrong wallsets are being loaded on my levels

My dev folders are now massive and complicated and it's virtually impossible to now send you the entire uncompiled folder of assets due to the size.

Is there a way we can debug this?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

I don't know how to debug this.
There isn't anything inherently wrong with using a compiled file, as best as I can tell, anyway.

Are you sure that the file being compiled was the only difference?
DSB loads .lua files first, and then loads .lxx files, so make sure that it's actually loading the right files.
Because of this, to prevent interference from your .lua files, the most expedient way to test a compiled dungeon is by moving stuff to a separate directory. If you were you doing that, are you sure there wasn't an old dungeon.dsb, old compiled files, or something in there?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Actually, I've not even compiled the Lua files, just the dungeon.dsb and the graphics dsb. Then I put those in a fresh folder along with all the *.lua files, and all the music/sounds that needed to be there too. It's all totally 'fresh'.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

I don't know. :(

Hmm.. I guess the first thing is, what do you mean by "don't load?" Do they not appear, or DSB gives an error, or what?

The wrong wallsets being displayed really sounds like a case of the wallset's id being different in dungeon.dsb and in whatever graphics.lua file you're using to declare your wallsets. That's why I asked you to make sure you were using a consistent set of files. Are you sure you didn't rearrange something after you had already compiled your dungeon?
(e.g., if you comment out or uncomment code creating an entry in the wallset table after compiling a dungeon.dsb, any wallsets after that one will be displayed wrong because the id numbers are now different. The only fix is to put it back or to recompile.)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

The portraits appear correctly once you enter the dungeon, but they just display a blank box in the champion selector. No errors. I'll review my code, perhaps it's a path error or something.
As for the wallsets, I'm pretty sure I didn't change anything, but I'll do a fresh compile and try again.

EDIT: OK, a fresh compile still has the same issues. It seems like the last defined wallset in my graphics.lua is being used everywhere, but I'm not 100% sure about that. I'll do some tests swapping out the wall types...

EDIT2: Yes, I can confirm this: The compiled version of the file ignores all wall bitmaps except for the last wallset defined. So if I define say WALL_SAND, WALL_GOLD & WALL_ICE in that order in my graphics.lua, then assign those wallsets to different levels, DSB is showing the bitmaps for WALL_ICE on all the levels. (It also uses WALL_ICE in any alt_wallset floor/wallitems). DSB does respect the different offsets specified in the other wallsets though, just not the bitmaps themselves.

Still no idea why portraits aren't showing though!

EDIT: Portraits issue now fixed, sent you a PM about it. :-)
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

When you say "compiled files," you mean a dungeon.dsb and graphics.dsb, right?
I've tried setting up multiple wallsets and I don't have this problem with compiled files.

One good test would be to see if the problem happens with a compiled dungeon.dsb and loading your graphics separately, a compiled graphics.dsb and loading the dungeon from dungeon.lua, or only when both are the compiled version.

Maybe it's some odd way that you've written the code to define your wallsets?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Here's my code. The only thing that might be considered 'odd' is that I change the path to each folder of wall images between each wallset declaration. Perhaps this is ignored somehow after compilation and therefore only the last images defined in the last folder are being accessed by the engine?

Code: Select all

-- Rocky Walls, Grey & Green Moss
path = pathimg .. "walls/rock2/"
gfx.wall_rock2_floor = dsb_get_bitmap(path .. "rock2-floor")
gfx.wall_rock2_roof = dsb_get_bitmap(path .. "rock2-roof")
gfx.wall_rock2_s0 = dsb_get_bitmap(path .. "rock2-wall_side0")
gfx.wall_rock2_s0alt = dsb_get_bitmap(path .. "rock2-wall_side0_alt")
gfx.wall_rock2_s1 = dsb_get_bitmap(path .. "rock2-wall_side1")
gfx.wall_rock2_s1alt = dsb_get_bitmap(path .. "rock2-wall_side1_alt")
gfx.wall_rock2_s1.x_off = -8
gfx.wall_rock2_s1alt.x_off = -8
gfx.wall_rock2_s2 = dsb_get_bitmap(path .. "rock2-wall_side2")
gfx.wall_rock2_s2alt = dsb_get_bitmap(path .. "rock2-wall_side2_alt")
gfx.wall_rock2_s3 = dsb_get_bitmap(path .. "rock2-wall_side3")
gfx.wall_rock2_s3alt = dsb_get_bitmap(path .. "rock2-wall_side3_alt")
gfx.wall_rock2_s3far = dsb_get_bitmap(path .. "rock2-wall_far3")
gfx.wall_rock2_s3faralt = dsb_get_bitmap(path .. "rock2-wall_far3_alt")
gfx.wall_rock2_front1 = dsb_get_bitmap(path .. "rock2-wall_front1")
gfx.wall_rock2_left1 = dsb_get_bitmap(path .. "rock2-wall_left1")
gfx.wall_rock2_left1alt = dsb_get_bitmap(path .. "rock2-wall_left1_alt")
gfx.wall_rock2_front1.y_off = -18
gfx.wall_rock2_left1.y_off = -18
gfx.wall_rock2_left1alt.y_off = -18
gfx.wall_rock2_front2 = dsb_get_bitmap(path .. "rock2-wall_front2")
gfx.wall_rock2_left2 = dsb_get_bitmap(path .. "rock2-wall_left2")
gfx.wall_rock2_left2alt = dsb_get_bitmap(path .. "rock2-wall_left2_alt")
gfx.wall_rock2_front3 = dsb_get_bitmap(path .. "rock2-wall_front3")
gfx.wall_rock2_left3 = dsb_get_bitmap(path .. "rock2-wall_left3")
gfx.wall_rock2_left3alt = dsb_get_bitmap(path .. "rock2-wall_left3_alt")
gfx.wall_rock2_window = dsb_get_bitmap(path .. "rock2-window")

wallset.rock2 = dsb_make_wallset_ext(
	gfx.wall_rock2_floor, gfx.wall_rock2_roof,
	gfx.wall_rock2_s0, gfx.wall_rock2_s0alt,
	gfx.wall_rock2_s1, gfx.wall_rock2_s1alt,
	gfx.wall_rock2_s2, gfx.wall_rock2_s2alt,
	gfx.wall_rock2_s3, gfx.wall_rock2_s3alt,
	gfx.wall_rock2_s3far, gfx.wall_rock2_s3faralt,
	gfx.wall_rock2_front1, gfx.wall_rock2_front2, gfx.wall_rock2_front3,
	gfx.wall_rock2_left1, gfx.wall_rock2_left1alt,
	gfx.wall_rock2_left2, gfx.wall_rock2_left2alt,
	gfx.wall_rock2_left3, gfx.wall_rock2_left3alt,
	gfx.wall_rock2_window)
	
-- Simple Bricks, sandy yellow/orangey
path = pathimg .. "walls/brick-sandy/"
gfx.wall_bricksandy_floor = dsb_get_bitmap(path .. "floor")
gfx.wall_bricksandy_roof = dsb_get_bitmap(path .. "roof")
gfx.wall_bricksandy_s0 = dsb_get_bitmap(path .. "wall_side0")
gfx.wall_bricksandy_s0alt = dsb_get_bitmap(path .. "wall_side0_alt")
gfx.wall_bricksandy_s1 = dsb_get_bitmap(path .. "wall_side1")
gfx.wall_bricksandy_s1alt = dsb_get_bitmap(path .. "wall_side1_alt")
gfx.wall_bricksandy_s2 = dsb_get_bitmap(path .. "wall_side2")
gfx.wall_bricksandy_s2alt = dsb_get_bitmap(path .. "wall_side2_alt")
gfx.wall_bricksandy_s2.x_off = 2
gfx.wall_bricksandy_s2alt.x_off = 2
gfx.wall_bricksandy_s3 = dsb_get_bitmap(path .. "wall_side3")
gfx.wall_bricksandy_s3alt = dsb_get_bitmap(path .. "wall_side3_alt")
gfx.wall_bricksandy_s3far = dsb_get_bitmap(path .. "wall_far3")
gfx.wall_bricksandy_s3faralt = dsb_get_bitmap(path .. "wall_far3_alt")
gfx.wall_bricksandy_front1 = dsb_get_bitmap(path .. "wall_front1")
gfx.wall_bricksandy_front2 = dsb_get_bitmap(path .. "wall_front2")
gfx.wall_bricksandy_front3 = dsb_get_bitmap(path .. "wall_front3")
gfx.wall_bricksandy_left1 = dsb_get_bitmap(path .. "wall_left1")
gfx.wall_bricksandy_left1alt = dsb_get_bitmap(path .. "wall_left1_alt")
gfx.wall_bricksandy_left2 = dsb_get_bitmap(path .. "wall_left2")
gfx.wall_bricksandy_left2alt = dsb_get_bitmap(path .. "wall_left2_alt")
gfx.wall_bricksandy_left3 = dsb_get_bitmap(path .. "wall_left3")
gfx.wall_bricksandy_left3alt = dsb_get_bitmap(path .. "wall_left3_alt")
gfx.wall_bricksandy_window = dsb_get_bitmap(path .. "window")

wallset.brick_sandy = dsb_make_wallset_ext(
	gfx.wall_bricksandy_floor, gfx.wall_bricksandy_roof,
	gfx.wall_bricksandy_s0, gfx.wall_bricksandy_s0alt,
	gfx.wall_bricksandy_s1, gfx.wall_bricksandy_s1alt,
	gfx.wall_bricksandy_s2, gfx.wall_bricksandy_s2alt,
	gfx.wall_bricksandy_s3, gfx.wall_bricksandy_s3alt,
	gfx.wall_bricksandy_s3far, gfx.wall_bricksandy_s3faralt,
	gfx.wall_bricksandy_front1, gfx.wall_bricksandy_front2, gfx.wall_bricksandy_front3,
	gfx.wall_bricksandy_left1, gfx.wall_bricksandy_left1alt,
	gfx.wall_bricksandy_left2, gfx.wall_bricksandy_left2alt,
	gfx.wall_bricksandy_left3, gfx.wall_bricksandy_left3alt,
	gfx.wall_bricksandy_window)
	
-- Simple Bricks, sandy but more realistic
path = pathimg .. "walls/brick-sandy-real/"
gfx.wall_bricksandy_floor = dsb_get_bitmap(path .. "floor")
gfx.wall_bricksandy_roof = dsb_get_bitmap(path .. "roof")
gfx.wall_bricksandy_s0 = dsb_get_bitmap(path .. "wall_side0")
gfx.wall_bricksandy_s0alt = dsb_get_bitmap(path .. "wall_side0_alt")
gfx.wall_bricksandy_s1 = dsb_get_bitmap(path .. "wall_side1")
gfx.wall_bricksandy_s1alt = dsb_get_bitmap(path .. "wall_side1_alt")
gfx.wall_bricksandy_s1.y_off = 0
gfx.wall_bricksandy_s1alt.y_off = 0
gfx.wall_bricksandy_s2 = dsb_get_bitmap(path .. "wall_side2")
gfx.wall_bricksandy_s2alt = dsb_get_bitmap(path .. "wall_side2_alt")
gfx.wall_bricksandy_s2.x_off = 0
gfx.wall_bricksandy_s2alt.x_off = 0
gfx.wall_bricksandy_s3 = dsb_get_bitmap(path .. "wall_side3")
gfx.wall_bricksandy_s3alt = dsb_get_bitmap(path .. "wall_side3_alt")
gfx.wall_bricksandy_s3far = dsb_get_bitmap(path .. "wall_far3")
gfx.wall_bricksandy_s3faralt = dsb_get_bitmap(path .. "wall_far3_alt")
gfx.wall_bricksandy_front1 = dsb_get_bitmap(path .. "wall_front1")
gfx.wall_bricksandy_front2 = dsb_get_bitmap(path .. "wall_front2")
gfx.wall_bricksandy_front2.x_off = 0
gfx.wall_bricksandy_front3 = dsb_get_bitmap(path .. "wall_front3")
gfx.wall_bricksandy_left1 = dsb_get_bitmap(path .. "wall_left1")
gfx.wall_bricksandy_left1alt = dsb_get_bitmap(path .. "wall_left1_alt")
gfx.wall_bricksandy_left2 = dsb_get_bitmap(path .. "wall_left2")
gfx.wall_bricksandy_left2alt = dsb_get_bitmap(path .. "wall_left2_alt")
gfx.wall_bricksandy_left3 = dsb_get_bitmap(path .. "wall_left3")
gfx.wall_bricksandy_left3alt = dsb_get_bitmap(path .. "wall_left3_alt")
gfx.wall_bricksandy_window = dsb_get_bitmap(path .. "window")

wallset.brick_sandy_real = dsb_make_wallset_ext(
	gfx.wall_bricksandy_floor, gfx.wall_bricksandy_roof,
	gfx.wall_bricksandy_s0, gfx.wall_bricksandy_s0alt,
	gfx.wall_bricksandy_s1, gfx.wall_bricksandy_s1alt,
	gfx.wall_bricksandy_s2, gfx.wall_bricksandy_s2alt,
	gfx.wall_bricksandy_s3, gfx.wall_bricksandy_s3alt,
	gfx.wall_bricksandy_s3far, gfx.wall_bricksandy_s3faralt,
	gfx.wall_bricksandy_front1, gfx.wall_bricksandy_front2, gfx.wall_bricksandy_front3,
	gfx.wall_bricksandy_left1, gfx.wall_bricksandy_left1alt,
	gfx.wall_bricksandy_left2, gfx.wall_bricksandy_left2alt,
	gfx.wall_bricksandy_left3, gfx.wall_bricksandy_left3alt,
	gfx.wall_bricksandy_window)	
	
-- Simple Bricks, sandy but more realistic [TALL]
path = pathimg .. "walls/brick-sandy-real-tall/"
gfx.wall_bricksandy_tall_floor = dsb_get_bitmap(path .. "floor")
gfx.wall_bricksandy_tall_roof = dsb_get_bitmap(path .. "roof")
gfx.wall_bricksandy_tall_s0 = dsb_get_bitmap(path .. "wall_side0")
gfx.wall_bricksandy_tall_s0alt = dsb_get_bitmap(path .. "wall_side0_alt")
gfx.wall_bricksandy_tall_s1 = dsb_get_bitmap(path .. "wall_side1")
gfx.wall_bricksandy_tall_s1alt = dsb_get_bitmap(path .. "wall_side1_alt")
gfx.wall_bricksandy_tall_s1.y_off = -18
gfx.wall_bricksandy_tall_s1alt.y_off = -18
gfx.wall_bricksandy_tall_s2 = dsb_get_bitmap(path .. "wall_side2")
gfx.wall_bricksandy_tall_s2alt = dsb_get_bitmap(path .. "wall_side2_alt")
gfx.wall_bricksandy_tall_s2.y_off = -40
gfx.wall_bricksandy_tall_s2alt.y_off = -40
gfx.wall_bricksandy_tall_s2.x_off = 0
gfx.wall_bricksandy_tall_s2alt.x_off = 0
gfx.wall_bricksandy_tall_s3 = dsb_get_bitmap(path .. "wall_side3")
gfx.wall_bricksandy_tall_s3alt = dsb_get_bitmap(path .. "wall_side3_alt")
gfx.wall_bricksandy_tall_s3.y_off = -50
gfx.wall_bricksandy_tall_s3alt.y_off = -50
gfx.wall_bricksandy_tall_s3far = dsb_get_bitmap(path .. "wall_far3")
gfx.wall_bricksandy_tall_s3faralt = dsb_get_bitmap(path .. "wall_far3_alt")
gfx.wall_bricksandy_tall_s3far.y_off = -50
gfx.wall_bricksandy_tall_s3faralt.y_off = -50
gfx.wall_bricksandy_tall_front1 = dsb_get_bitmap(path .. "wall_front1")
gfx.wall_bricksandy_tall_front1.y_off = -18
gfx.wall_bricksandy_tall_front2 = dsb_get_bitmap(path .. "wall_front2")
gfx.wall_bricksandy_tall_front2.y_off = -40
gfx.wall_bricksandy_tall_front3 = dsb_get_bitmap(path .. "wall_front3")
gfx.wall_bricksandy_tall_front3.y_off = -50
gfx.wall_bricksandy_tall_left1 = dsb_get_bitmap(path .. "wall_left1")
gfx.wall_bricksandy_tall_left1alt = dsb_get_bitmap(path .. "wall_left1_alt")
gfx.wall_bricksandy_tall_left1.y_off = -18
gfx.wall_bricksandy_tall_left1alt.y_off = -18
gfx.wall_bricksandy_tall_left2 = dsb_get_bitmap(path .. "wall_left2")
gfx.wall_bricksandy_tall_left2alt = dsb_get_bitmap(path .. "wall_left2_alt")
gfx.wall_bricksandy_tall_left2.y_off = -40
gfx.wall_bricksandy_tall_left2alt.y_off = -40
gfx.wall_bricksandy_tall_left3 = dsb_get_bitmap(path .. "wall_left3")
gfx.wall_bricksandy_tall_left3alt = dsb_get_bitmap(path .. "wall_left3_alt")
gfx.wall_bricksandy_tall_left3.y_off = -50
gfx.wall_bricksandy_tall_left3alt.y_off = -50
gfx.wall_bricksandy_tall_window = dsb_get_bitmap(path .. "window")

wallset.brick_sandy_real_tall = dsb_make_wallset_ext(
	gfx.wall_bricksandy_tall_floor, gfx.wall_bricksandy_tall_roof,
	gfx.wall_bricksandy_tall_s0, gfx.wall_bricksandy_tall_s0alt,
	gfx.wall_bricksandy_tall_s1, gfx.wall_bricksandy_tall_s1alt,
	gfx.wall_bricksandy_tall_s2, gfx.wall_bricksandy_tall_s2alt,
	gfx.wall_bricksandy_tall_s3, gfx.wall_bricksandy_tall_s3alt,
	gfx.wall_bricksandy_tall_s3far, gfx.wall_bricksandy_tall_s3faralt,
	gfx.wall_bricksandy_tall_front1, gfx.wall_bricksandy_tall_front2, gfx.wall_bricksandy_tall_front3,
	gfx.wall_bricksandy_tall_left1, gfx.wall_bricksandy_tall_left1alt,
	gfx.wall_bricksandy_tall_left2, gfx.wall_bricksandy_tall_left2alt,
	gfx.wall_bricksandy_tall_left3, gfx.wall_bricksandy_tall_left3alt,
	gfx.wall_bricksandy_tall_window)

-- Royal Chambers, Gold
path = pathimg .. "walls/royal-gold/"
gfx.wall_royal_gold_floor = dsb_get_bitmap(path .. "floor")
gfx.wall_royal_gold_roof = dsb_get_bitmap(path .. "roof")
gfx.wall_royal_gold_s0 = dsb_get_bitmap(path .. "wall_side0")
gfx.wall_royal_gold_s0alt = dsb_get_bitmap(path .. "wall_side0_alt")
gfx.wall_royal_gold_s1 = dsb_get_bitmap(path .. "wall_side1")
gfx.wall_royal_gold_s1alt = dsb_get_bitmap(path .. "wall_side1_alt")
gfx.wall_royal_gold_s2 = dsb_get_bitmap(path .. "wall_side2")
gfx.wall_royal_gold_s2alt = dsb_get_bitmap(path .. "wall_side2_alt")
gfx.wall_royal_gold_s2.x_off = 0
gfx.wall_royal_gold_s2alt.x_off = 0
gfx.wall_royal_gold_s2.y_off = 2
gfx.wall_royal_gold_s2alt.y_off = 2
gfx.wall_royal_gold_s3 = dsb_get_bitmap(path .. "wall_side3")
gfx.wall_royal_gold_s3alt = dsb_get_bitmap(path .. "wall_side3_alt")
gfx.wall_royal_gold_s3far = dsb_get_bitmap(path .. "wall_far3")
gfx.wall_royal_gold_s3faralt = dsb_get_bitmap(path .. "wall_far3_alt")
gfx.wall_royal_gold_front1 = dsb_get_bitmap(path .. "wall_front1")
gfx.wall_royal_gold_front2 = dsb_get_bitmap(path .. "wall_front2")
gfx.wall_royal_gold_front3 = dsb_get_bitmap(path .. "wall_front3")
-- gfx.wall_royal_gold_front3.x_off = 2
gfx.wall_royal_gold_left1 = dsb_get_bitmap(path .. "wall_left1")
gfx.wall_royal_gold_left1alt = dsb_get_bitmap(path .. "wall_left1_alt")
gfx.wall_royal_gold_left2 = dsb_get_bitmap(path .. "wall_left2")
gfx.wall_royal_gold_left2alt = dsb_get_bitmap(path .. "wall_left2_alt")
gfx.wall_royal_gold_left3 = dsb_get_bitmap(path .. "wall_left3")
gfx.wall_royal_gold_left3alt = dsb_get_bitmap(path .. "wall_left3_alt")
gfx.wall_royal_gold_window = dsb_get_bitmap(path .. "window")

wallset.royal_gold = dsb_make_wallset_ext(
	gfx.wall_royal_gold_floor, gfx.wall_royal_gold_roof,
	gfx.wall_royal_gold_s0, gfx.wall_royal_gold_s0alt,
	gfx.wall_royal_gold_s1, gfx.wall_royal_gold_s1alt,
	gfx.wall_royal_gold_s2, gfx.wall_royal_gold_s2alt,
	gfx.wall_royal_gold_s3, gfx.wall_royal_gold_s3alt,
	gfx.wall_royal_gold_s3far, gfx.wall_royal_gold_s3faralt,
	gfx.wall_royal_gold_front1, gfx.wall_royal_gold_front2, gfx.wall_royal_gold_front3,
	gfx.wall_royal_gold_left1, gfx.wall_royal_gold_left1alt,
	gfx.wall_royal_gold_left2, gfx.wall_royal_gold_left2alt,
	gfx.wall_royal_gold_left3, gfx.wall_royal_gold_left3alt,
	gfx.wall_royal_gold_window)


	
-- Icy Tall Walls
path = pathimg .. "walls/ice1/"
gfx.wall_ice1_floor = dsb_get_bitmap(path .. "floor")
gfx.wall_ice1_roof = dsb_get_bitmap(path .. "roof")
gfx.wall_ice1_roofd = dsb_get_bitmap(path .. "roof_black")
gfx.wall_ice1_s0 = dsb_get_bitmap(path .. "wall_side0")
gfx.wall_ice1_s0alt = dsb_get_bitmap(path .. "wall_side0_alt")
gfx.wall_ice1_s1 = dsb_get_bitmap(path .. "wall_side1")
gfx.wall_ice1_s1alt = dsb_get_bitmap(path .. "wall_side1_alt")
gfx.wall_ice1_s1.x_off = -64
gfx.wall_ice1_s1alt.x_off = -64
gfx.wall_ice1_s1.y_off = -18
gfx.wall_ice1_s1alt.y_off = -18
gfx.wall_ice1_s2 = dsb_get_bitmap(path .. "wall_side2")
gfx.wall_ice1_s2alt = dsb_get_bitmap(path .. "wall_side2_alt")
gfx.wall_ice1_s2.x_off = -120
gfx.wall_ice1_s2alt.x_off = -120
gfx.wall_ice1_s2.y_off = -40
gfx.wall_ice1_s2alt.y_off = -40
gfx.wall_ice1_s3 = dsb_get_bitmap(path .. "wall_side3")
gfx.wall_ice1_s3alt = dsb_get_bitmap(path .. "wall_side3_alt")
gfx.wall_ice1_s3.x_off = -148
gfx.wall_ice1_s3alt.x_off = -148
gfx.wall_ice1_s3.y_off = -50
gfx.wall_ice1_s3alt.y_off = -50
gfx.wall_ice1_s3far = dsb_get_bitmap(path .. "wall_far3")
gfx.wall_ice1_s3faralt = dsb_get_bitmap(path .. "wall_far3_alt")
gfx.wall_ice1_s3far.x_off = 0
gfx.wall_ice1_s3faralt.x_off = 0
gfx.wall_ice1_s3far.y_off = -50
gfx.wall_ice1_s3faralt.y_off = -50

gfx.wall_ice1_front1 = dsb_get_bitmap(path .. "wall_front1")
gfx.wall_ice1_front1.y_off = -18
gfx.wall_ice1_front1.x_off = -18
gfx.wall_ice1_front2 = dsb_get_bitmap(path .. "wall_front2")
gfx.wall_ice1_front2.y_off = -40
gfx.wall_ice1_front2.x_off = -23
gfx.wall_ice1_front3 = dsb_get_bitmap(path .. "wall_front3")
gfx.wall_ice1_front3.y_off = -50
gfx.wall_ice1_front3.x_off = -9

gfx.wall_ice1_left1 = dsb_get_bitmap(path .. "wall_left1")
gfx.wall_ice1_left1alt = dsb_get_bitmap(path .. "wall_left1_alt")
gfx.wall_ice1_left1.y_off = -18
gfx.wall_ice1_left1alt.y_off = -18
gfx.wall_ice1_left2 = dsb_get_bitmap(path .. "wall_left2")
gfx.wall_ice1_left2alt = dsb_get_bitmap(path .. "wall_left2_alt")
gfx.wall_ice1_left2.y_off = -40
gfx.wall_ice1_left2alt.y_off = -40
gfx.wall_ice1_left3 = dsb_get_bitmap(path .. "wall_left3")
gfx.wall_ice1_left3alt = dsb_get_bitmap(path .. "wall_left3_alt")
gfx.wall_ice1_left3.y_off = -50
gfx.wall_ice1_left3alt.y_off = -50
gfx.wall_ice1_window = dsb_get_bitmap(path .. "window")

wallset.ice1 = dsb_make_wallset_ext(
	gfx.wall_ice1_floor, gfx.wall_ice1_roof,
	gfx.wall_ice1_s0, gfx.wall_ice1_s0alt,
	gfx.wall_ice1_s1, gfx.wall_ice1_s1alt,
	gfx.wall_ice1_s2, gfx.wall_ice1_s2alt,
	gfx.wall_ice1_s3, gfx.wall_ice1_s3alt,
	gfx.wall_ice1_s3far, gfx.wall_ice1_s3faralt,
	gfx.wall_ice1_front1, gfx.wall_ice1_front2, gfx.wall_ice1_front3,
	gfx.wall_ice1_left1, gfx.wall_ice1_left1alt,
	gfx.wall_ice1_left2, gfx.wall_ice1_left2alt,
	gfx.wall_ice1_left3, gfx.wall_ice1_left3alt,
	gfx.wall_ice1_window)
	
wallset.ice1d = dsb_make_wallset_ext(
	gfx.wall_ice1_floor, gfx.wall_ice1_roofd,
	gfx.wall_ice1_s0, gfx.wall_ice1_s0alt,
	gfx.wall_ice1_s1, gfx.wall_ice1_s1alt,
	gfx.wall_ice1_s2, gfx.wall_ice1_s2alt,
	gfx.wall_ice1_s3, gfx.wall_ice1_s3alt,
	gfx.wall_ice1_s3far, gfx.wall_ice1_s3faralt,
	gfx.wall_ice1_front1, gfx.wall_ice1_front2, gfx.wall_ice1_front3,
	gfx.wall_ice1_left1, gfx.wall_ice1_left1alt,
	gfx.wall_ice1_left2, gfx.wall_ice1_left2alt,
	gfx.wall_ice1_left3, gfx.wall_ice1_left3alt,
	gfx.wall_ice1_window)	
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

Gambit37 wrote:Perhaps this is ignored somehow after compilation and therefore only the last images defined in the last folder are being accessed by the engine?
That is sort of what's going on.

You're using a path as a short name for the graphics resource. While this isn't inherently wrong, it is a little weird, and this means DSB comes up with a proper short name itself. In this case, it's assigning multiple graphics the same short name because multiple files have the same filename-- they're distinguished only by path. So this all gets rammed together when the graphics.dsb is compiled.

Here's a quick and dirty fix. Put this at the top of your code.

Code: Select all

gt_shortid = 1
function get_wallset_bitmap(longname)
  local shortname = "WSBMP" .. gt_shortid
  gt_shortid = gt_shortid + 1
  local my_bmp = dsb_get_bitmap(shortname, longname .. ".png")
  return my_bmp
end
Then just use whatever editor function to replace all instances of dsb_get_bitmap in this code with get_wallset_bitmap.

What this does is take your current weird name and add an extension so it can be taken as a full path. Then, it creates (using a very dumb algorithm) a unique shortname for graphics.dsb.

There are two main limitations to this code:
:arrow: It requires that the file extension be .png. You can change this if you need to, of course, but that's probably not a big deal because that seems to be what you're using anyway.
:arrow: If you change around the order of your wallsets or add new ones, you will need to recompile graphics.dsb.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Aha! Right, that makes sense. Yes, I wanted to keep the filenames the same so that I could easily and quickly duplicate a wallset folder (makes it easier to know what files to export each image to from PhotoShop). Thanks for the fix, I'll give it a go :-)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Compiling Lua files?

Post by Gambit37 »

Woo hoo, OK, everything now works. Thanks :-)
I've cleaned up all my short-name/long name issues, re-organised my files and did a full compile (*.dsb & *.lxx) and everything works perfectly now. :-)
I found that if I put all my linked files in a sub-folder, correctly referenced in my startup.lua and objects.lua, then all I need in my root dungeon folder are:

graphics.dsb
dungeon.dsb
startup.lxx
objects.lxx
*.mp3

Nice! This keeps things much cleaner and easier to work with. :-)
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Compiling Lua files?

Post by Sophia »

By the way dsb_music will automatically truncate its short name just like your wallset code, so you could do dsb_music("MP3/MYSONG") and it will load mp3/mysong.mp3, and, if it can't find that, try to load MYSONG from graphics.dsb. The usual caveat about files with the same short name applies.
Post Reply