Specifying images for wallitems at different ranges

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
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Specifying images for wallitems at different ranges

Post by meadwarrior »

Hello!

How would I go about specifying images for wallitems at different ranges?

I guess it's something I'd have to define in my graphics.lua, but how?

Thanks!
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Specifying images for wallitems at different ranges

Post by Sophia »

You just need to specify front_med, front_far, side_med, and side_far bitmaps. There are no examples of wallitems that use these bitmaps in the DSB base code, but it's similar enough to the way it works for floor objects (i.e., FLOORFLAT and FLOORUPRIGHT) that you can use those as examples.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Specifying images for wallitems at different ranges

Post by Gambit37 »

Also, these options are only in DSB 0.70+, so you'll need to update if still using 0.69.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Specifying images for wallitems at different ranges

Post by meadwarrior »

Thank you!

So I've made a custom objects.lua (and her manifest) like this, unfortunately when I try to start, I get this error:

Image

(I used the hook_front graphic in the 'side' specifications for quickly testing it out).
I'm using DSB 0.71.

What did I miss?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Specifying images for wallitems at different ranges

Post by Sophia »

You don't need to (and shouldn't) put objects.lua in the lua_manifest.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Specifying images for wallitems at different ranges

Post by meadwarrior »

Thank you!

That got rid of the error, but now it doesn't show the hook object at all...

Even if I delete it from my objects.lua (this should reset it to the default hook, right?), there's no graphic shown in the editor...
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Specifying images for wallitems at different ranges

Post by Gambit37 »

Make sure you reload the dungeon in ESB after making any changes to your Lua files. If you leave the editor open while coding and forget to reload the dungeon after changing your code, you can get into an awful pickle...

If that doesn't solve it, try NOT re-declaring the entire object. So in your objects.lua, just specify individual properties that you want to add or override. For example, in mine, I just need to tweak offsets, so I added this:

Code: Select all

gfx.hook_front.y_off = 8
gfx.hook_front.x_off = 1
gfx.hook_front.mid_y_tweak = 3
gfx.hook_front.far_y_tweak = 4
gfx.hook_side.y_off = 4
gfx.hook_side.x_off = -20
gfx.hook_side.mid_x_tweak = 1
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Specifying images for wallitems at different ranges

Post by meadwarrior »

Thanks!

After reloading the dungeon in ESB, all the default objects work again.

The objects in my own objects.lua are still missing/not being shown in the game, however.
This is how I set them up.

Code: Select all

obj.temple01_roof = {
	type="WALLITEM",
	class="DECO",
	front=gfx.temple01_roof_front[1],
	front_med=gfx.temple01_roof_front_med[2],
	front_far=gfx.temple01_roof_front_far[3],
	side=gfx.temple01_roof_side[1],
	side_med=gfx.temple01_roof_side_med[2],
	side_far=gfx.temple01_roof_side_far[3],
	wall_patch=true,
	on_click=wallitem_click
}
Is there something wrong with the code?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Specifying images for wallitems at different ranges

Post by Gambit37 »

When a graphic name is followed by [x], DSB expects to find the images defined in a table, which is generally how floor item graphics are defined such as this example from the base/graphics.lua:

Code: Select all

gfx.doorframe_front = {
  [0] = dsb_get_bitmap("DOORFRAME_FRONT0"),
  [1] = dsb_get_bitmap("DOORFRAME_FRONT1"),
  [2] = dsb_get_bitmap("DOORFRAME_FRONT2"),
  [3] = dsb_get_bitmap("DOORFRAME_FRONT3")
}
When you refer to gfx.doorframe_front[0], for example, you'll get back the bitmap for that entry in the table.

But wallitems don't need that , they use the simpler "one graphic per entry" approach, eg:

Code: Select all

gfx.fountain_lion_front = dsb_get_bitmap("FOUNTAIN_LION_FRONT")
gfx.fountain_lion_side = dsb_get_bitmap("FOUNTAIN_LION_SIDE")
So just make sure that you define your graphics for wall items in the simpler way, and remove those [X] numbers from your object, eg:

Code: Select all

obj.temple01_roof = {
	type="WALLITEM",
	class="DECO",
	front=gfx.temple01_roof_front,
	front_med=gfx.temple01_roof_front_med,
	front_far=gfx.temple01_roof_front_far,
	side=gfx.temple01_roof_side,
	side_med=gfx.temple01_roof_side_med,
	side_far=gfx.temple01_roof_side_far,
	wall_patch=true,
	on_click=wallitem_click
}
The reason your graphics aren't showing up is because you're asking DSB to look for graphics in a table which doesn't exist. At least, I think that's what's happening. :)
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Specifying images for wallitems at different ranges

Post by meadwarrior »

That's exactly what happened!
Thank you very much for the detailed explanation, Gambit, it really helped a lot. I thought that the numbers were related to the size of the graphics.

As a bonus, I now know how to define flooritems in a list ;)

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

Re: Specifying images for wallitems at different ranges

Post by Gambit37 »

You're welcome, glad it helped. :)
Post Reply