Tutorials: wallsets and custom monsters, objects, etc

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. You may Image to help finance the hosting costs of this forum.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Hi all, could someone point me at a tutorial or two for creating custom wallsets and custom monsters in DSB?

I wanted to tinker around again with DSB, but I don’t have my files any more (from over a decade ago) where I’d successfully cracked how to do these things.

Basically I have a lot of custom wallsets and graphics I developed for an RTC project that I want to see if I can get into DSB. Any pointers much appreciated! :D
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ok so have done some reverse engineering via some of the custom CSB dungeons.

Custom graphics: Looks like I can load custom graphics like this in a graphics_new.lua, where the bitmap (ND_FRNT for example) is stored locally to the lua file.

Code: Select all

gfx.newdragon_front = dsb_get_bitmap ("ND_FRNT")
gfx.newdragon__side = dsb_get_bitmap ("ND_DSIDE")
gfx.newdragon__back = dsb_get_bitmap ("ND_BACK")
gfx.newdragon__attack = dsb_get_bitmap ("ND_ATT")
I understand this new graphics lua file can be a separate file to the dungeon file, but needs to be called off from the manifest

To create a "new" monster, I can add something like this to the objects.lua file:

Code: Select all

obj.newdragon = clone_arch(obj.dragon, {
    front = gfx.newdragon_front,
    side = gfx.newdragon_side,
    back = gfx.newdragon_back,
    attack = gfx.newdragon_attack,
    quickness=100,
    base_power=280,
    missile_power=185,
    missile_damage=90,
} )
Need to now get my head around custom wallsets.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Problem is: when testing the dungoen from ESB, I am getting an error message saying:

FATAL LUA ERROR
....objects.lua:3:attempt to index global 'obj' (a nil value)

Any ideas anyone? Much appreciated
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

You get that error because obj isn't defined. Either you're trying to define objects in the wrong place or you've written some bad code that obliterates obj. Without seeing your code I don't know which it is.

A DSB ext wallset is designed to be drop-in compatible with an RTC wallset, so you should have a fairly easy time porting it over. The actual way wallsets are defined in DSB is a little clunky, admittedly, but the syntax is explained on the wiki.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Many thanks Sophia. I’m not sure how to define an obj I guess - where/how is this done?

I created an Objects.lua where it contains the cloning of the dragon monster to a ‘newdragon’ (as per code above, and (I think) as per your tutorials, which I somehow missed, apologies). This objects.lua is referenced in a startup.lua file with the manifest code.

I can get the object appearing in ESB, it’s just when it runs it creates that error. Is it something to do with the order of things loading? I read a bit about that, but didn't quite understand it.

Thank you🙏
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

ebeneezergude wrote: Thu Jan 16, 2025 8:32 pm This objects.lua is referenced in a startup.lua file with the manifest code.
Your problem is right here. You don't need to add objects.lua to the lua_manifest. It is automatically parsed later in the loading process. Take it out and things should work fine!
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ahhhh.... got it. Yes that works. Thank you so much!

Now getting into wallsets (and doorframes and stairs to match....) On the dsb_make_wallset_ext:

Code: Select all

dsb_make_wallset_ext(floor, roof, pers0, pers0alt, pers1, pers1alt, pers2, pers2alt, pers3, persl3alt, farwall3, farwall3alt, front1, front2, front3, left1, left1alt, left2, left2alt, left3, left3alt, patch1, patch2, patch3, patchside, window) = wallset
...does "floor" need to be called "floor" in every wallset (I''m planning on using multiple different designs of walls), or is it able to be called anything, as long as it matches the name of a bitmap called into gfx in the graphics.lua, and it appears in the right order in this list of items within the parentheses? Is there an example code of this working? I'm planning to utilise bitmaps made originally for RTC using the RTCWM programme. How can I differentiate between the different wallsets, basically?

Thank you Sophia.
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

Here's an example from an (unreleased) dungeon I made a while ago:

Code: Select all

wallset.tomb = dsb_make_wallset_ext(gfx.rough_floor, gfx.rough_roof, gfx.rough_pers0,
	gfx.rough_pers0alt, gfx.rough_pers1, gfx.rough_pers1alt, gfx.rough_pers2,
	gfx.rough_pers2alt, gfx.rough_pers3, gfx.rough_pers3alt, gfx.rough_far3,
	gfx.rough_far3alt, gfx.rough_front1, gfx.rough_front2, gfx.rough_front3,
	gfx.rough_left1, gfx.rough_left1alt, gfx.rough_left2, gfx.rough_left2alt,
	gfx.rough_left3, gfx.rough_left3alt, nil, nil, nil, nil, gfx.wallwindow)
As you can see, the graphics can be named anything. It's just the position that matters. You don't typically need to define "patch" bitmaps, and this code does not.

For what it's worth, I am aware DSB's way of defining wallsets is kind of awful and if I were ever going to do a big revision of DSB (like update the renderer to something modern) I'd definitely do something better. :P
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ok that makes sense. Much appreciated, I’ll give this a go.

Big picture is: essentially I would like to develop a project I started a long time ago in RTC, but am torn as to whether to stay in RTC or move over to DSB, which is actually pretty brilliant it seems - very quick, very nimble, very flexible and stable. RTC has some limitations and issues as you’re aware. I just need to work out how to do various things to replicate how it’s done in RTC, but all of the graphics assets I developed are reusable.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

So I''ve got this test in the graphics2.lua:

Code: Select all

gfx.dh_floor = dsb_get_bitmap("CUSTOM_FLOOR")
gfx.dh_roof = dsb_get_bitmap("CUSTOM_ROOF")

wallset.dhfloor = dsb_make_wallset_ext(gfx.dh_floor, gfx.dh_roof, gfx.pers0, gfx.pers0alt,
	gfx.pers1, gfx.pers1alt, gfx.pers2, gfx.pers2alt, gfx.pers3, gfx.pers3alt,
	gfx.farwall3, gfx.farwall3alt, gfx.front1, gfx.front2, gfx.front3,
	gfx.left1, gfx.left1alt, gfx.left2, gfx.left2alt, gfx.left3, gfx.left3alt, gfx.wallwindow)
	
And the corresponding two bmps (custom_floor, custom_roof) are in the same folder as dungeon.lua. The wallset does not appear in the ESB right hand menu for some reason.

Is there anywhere else I need to add code or "declare" this? Thanks!
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ah, I worked it out, using the Wallsets box in the ESB menu item Edit>Global Info. I can now see how this then implements the text in the dungeon.lua. Thanks!
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

So I have a basic wallset and door frames imported. Here's a side by side test of my RTC project and DSB.

Image

Some very, very minor differences in the way RTC and DSB render the bitmaps. Also the way DSB uses graphics seems quite smooth. It doesn't seem to need or use the same number of bitmaps as RTCWM generates or RTC uses, and the sizes are slightly different - doorframe graphics, for example.

I need to look into if/how in DSB I can do the custom user interface and menus. Is this doable? Looks like it, from reviewing the DSB Base graphics.lua.

Here is a short video of RTC of some of the test textures and custom UI, to demo how it would work out: https://youtu.be/1UV4Ox4wpUY?si=ikv5BX_FgNAqgumc
User avatar
Gambit37
Should eat more pies
Posts: 13769
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Gambit37 »

DSB can have its UI modified extensively, if you're happy to code in Lua. You can do everything shown in your RTC screenshot in DSB.

I'd recommend reading this thread which has years of me asking questions of Sophia and getting great answers: viewtopic.php?t=28859

I have an old work-in-progress "Dungeon Master Redux" to upgrade everything to a pseudo-256 colour version of DM and. Not sure if you've seen the screenshots, so here's some examples of what's possible. (I've barely scratched the surface with these changes, you could do very custom stuff that doesn't even look like DM.)

Image

Image

Image

Image

Image

Image

Image
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Thanks a lot Gambit, I’ll have a look at this thread. I’d just like to do graphics replacement, no other changes, will try to have a tinker later.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Regarding custom graphic bitmaps: Do I have to drop them in the same folder as the dungeon.lua and graphics2.lua, or can I put them in folders for better organisation? If so, how do I write the code for the path in my graphics2.lua? Sorry, appreciate this is probably super basic. Thanks!
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

You can specify a path to the bitmap. It's just optional.

Code: Select all

gfx.my_bmp = dsb_get_bitmap("MY_BITMAP", "folder/pics/my_bitmap.png")
The whole all-caps short name thing is necessary either way because these names are needed to compile the graphics into graphics.dsb.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Many thanks Sophia, makes sense now. Is there a way to say to DSB to look in specific folders, so as not to have to copy the path text for every graphic entry? Like a list of folders at the start of a graphics.lua file, to say to DSB "also look here" for assets?
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ok so am making some good progress porting over the RTC project. Have established a relatively quick way to import all the wallsets (lots of bitmaps!), and porting the monsters over seems quite easy and painless (big reliance on the 'base.lua' file here, it's indispensable).

Whilst this is all 'code' based, it's actually not that difficult, and probably as quick as setting it up in RTC (if not quicker perhaps?). It would be AMAZING to see graphic representation of things/monsters/doors etc inside ESB, but I am fully aware DSB is not being developed any more.

It would be amazing if there is a way to organise the bitmaps into folders, and then have DSB just scan the folders somehow. There are a lot of files ultimately and the base dungeon folder will get very populated. If not, no hassle, no major issue adding the path to each item, just makes the .luas potentially get quite fiddly.

Also I need to work out a way to potentially split stuff out to more .luas. A Monsters.lua, Items.Lua, different graphics.lua - is this something people do, or have done? I read a bit on Gambit's questions to Sophia on this - am not quite sure I understood the conclusion though!

I will also have a go at the custom UI graphics hopefully later.

Anyway, many thanks for all the help, much appreciated.
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

I guess it's both correct and incorrect to say that DSB is not being developed any more. I don't have the time or the will to make any major changes or upgrades, and that probably isn't changing any time soon, but I am also still around and bugs still get fixed, so it's not completely dead, either. Still, you're right that major upgrades to ESB are unlikely to happen.

Anyway, to answer your question, there's no direct way to specify a path, but Lua itself provides some handy techniques.

A simple way is to concatenate a string like this:

Code: Select all

local path = "folder/pics/"
gfx.my_bmp = dsb_get_bitmap("MY_BITMAP", path .. "my_bitmap.png")
This makes things shorter and makes it easier to change paths.

If you want to delve a little bit more into Lua code you can use the graphics_paths table, which is defined in graphics.cfg. DSB can't automatically scan or anything like that, but you can generate this table of key:value pairs corresponding long names with short names however you want to, so you can concatenate strings to automatically build paths or whatever else. For example, this code has the same effect:

Code: Select all

-- In graphics.cfg
graphics_paths = {
   MY_BITMAP = "folder/pics/my_bitmap.png"
}

Code: Select all

-- In your normal code
gfx.my_bmp = dsb_get_bitmap("MY_BITMAP")
Using graphics_paths also allows you to replace existing bitmaps without reloading anything or changing any code, because you can just change the path to the bitmap.

Splitting code off to more .lua files is what the lua_manifest is for. You can include files there and they will be loaded by DSB.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Thank you. That’s not a bad middle ground. I like the way it gives you flexibility with graphic locations and not have to re-edit lots of code.

I understand the manifest, I’ll split out more files then.

Another question if I may about asymmetrical flooritems. I’ve read a little bit again from one of Gambit’s questions; I think you had said to achieve an asymmetric item (viewed differently east / west than north / south) that a viewangle property can be implemented on two items on the same square to simulate one asymmetric item (a ‘hack’ as you put it).

Could you elaborate further on how this works, what the property values are, how to implement,etc? I couldn’t see anything in the DSB wiki on this. I have a couple of asymmetric items I’d like to port over from my original RTC project. Thank you!
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

Right, viewangle allows you to specify what directions an object is visible from, so by stacking up multiple instances in a square with different viewangle values, it will look like something that looks different depending on the direction.

The simplest way is to set the archetype's viewangle property to a direction: NORTH, SOUTH, EAST, or WEST. This will make any instances of the archetype visible from only that direction.

Alternatively, if you want an object to be visible from multiple directions, you can specify viewangle as a table of bools, in the order north, east, south, west. So, for example:

Code: Select all

obj.myobj.viewangle = { true, false, true, false }
This object is only visible if you are north or south; it is invisible from the east or west.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ah, this is brilliant thank you Sophia, I understand now.

Perhaps slightly silly question on buttons: When I click a button, how to I get it to visually pop out again into it's unpressed state? I'd like it to press in, activate something, and then reset itself to be in the unpressed position. If I use 'toggle', it opens and closes a door (for exmaple) on each press, but the button moves in, then only moves out on the next press. If I have two buttons operating the same door, one of them will look 'in' when I press it for the first time.

So basically, I want to get a button to always get back into the unpressed state - sort of like a momentary contact switch. Am I missing something really obvious?

Side question: why in the ESB menu for buttons / switches are each listed as in and out, and up and down? Ie each switch appears twice in the menu, on/off, or up/down. Is there a techncial reason?

Many thanks!
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Another super basic problem I am having regarding doors and door graphics:

I have created a new door object with a custom graphic bitmap, I copied one of the doors from the base objects.lua. It is not a clone. My door graphic does not appear in game. All the code seems to work, the door itself is there in-game (I can open, close, damage it, obstructs party walking, etc), but the graphic itself just is not appearing. I have tried to fix it by applying offsets to the graphic - in case it's some sort of coordinates issue - but this isn't seemingly working. I have disabled any 'deco' overlays on this object. The graphic is a .png, RGB 8-bit, same as all my other .pngs that are working in DSB.

I am at a loss to understand why it won't appear. I can even use the standard DM door.pcx with this new door, and this .pcx graphic will appear. So it seems to be something to do with the door grpahic itself. (May or may not be relevant, but this same door graphic .png works in RTC).

I feel like such a noob! Any ideas? Thank you.

Code in objects.lua

Code: Select all

obj.door_DH_wood_strong = {
	type="DOOR",
	class="WOOD",
	front=gfx.door_wooden_03,
	--deco=nil,
	bash_mask=gfx.door_bashed,
	col=door_collide,
	msg_handler=door_msg_handler,
	bash_power = 90,
	fire_power = 40
	}
Code in graphics2.lua

Code: Select all

--DH Doors
gfx.DOOR_WOODEN_03 = dsb_get_bitmap("DOOR_WOODEN_03")
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Regarding the doors graphic issue... I discovered the problem. I had caps for the door bitmap name in graphics.lua, and lowercase for the door graphic bitmap name in the objects file. Once I made them all Caps, it all works fine... I hadn't appreciated caps made a difference....ugh... [holds head in shame]
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Trying to implement a custom door button results in the button appearing and being usable, but not positioned correctly on the door frame. It just appears to be positioned relative to the floor tile and the tile quadrant positions or centre position for that square.

How do I make it associate with, or sit on, the doorframe? Thank you!
User avatar
Gambit37
Should eat more pies
Posts: 13769
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Gambit37 »

I got stuck on this too when I last worked on my graphics mod. It wasn't possible to position the button correctly in the version of DSB I was using at the time (0.76 I think). I believe there's some updates since then to fix the problem. There was a thread about it here: viewtopic.php?t=31368 (wow, over four years ago! I really need to finish this mod!)
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Thanks so much Gambit. What I did was to draw the button onto a new doorframe graphic, then copy doorbutton.pcx from the DSB base graphics into my dungeon folder, and make it 100% magenta to make it invisible, then add it as normal to the dungeon in ESB, so it sits over the new_doorframe_with_button_drawn_on bitmap. This seems to work... it's a bit sketchy though...! Is that what you did in your thread when you said you would "precompose" the button onto the door frame?
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

ebeneezergude wrote: Sun Jan 19, 2025 11:03 am Side question: why in the ESB menu for buttons / switches are each listed as in and out, and up and down? Ie each switch appears twice in the menu, on/off, or up/down. Is there a techncial reason?
Yes, the technical reason is that the two different button states are just distinct objects. When you press a button, internally, it is just a qswap (i.e., a swap that does nothing but change the archetype) between the two different button archetypes.

This also gives you an answer how to pop the button back out again: Just add a qswapper that targets the button and swaps it back.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Really sorry, I can't work out how to implement this dsb_qswap / qswapper... I've read the wiki, but I don't understand it and how to implement it. Could you spell it out if possible? Much appreciated.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

And I meant to add one more: how can I click on a wallitem (or on a wall), and have it generate text at the bottom of the game screen? Essentially, like the floor text mechanic generates text. I presume this is probably easy, but I am not clear on how one would go about setting this up though. Many thanks!

I also implemented the _med and _far for wall item graphics, in conjunction with .x_off and .y_off for their graphic positions, having read about these on the threads here. Very useful indeed.
Post Reply