Better wall writing...?

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:

Better wall writing...?

Post by Gambit37 »

I'd like to change the "carved stone" wall-writing into text that's displayed on a nice plaque, or tapestry.

I know there's a wall-writing render hack which manages all the masking and cropping for wall text. I think I can still use this, but I'm not sure how to render that text into a new bitmap of my plaque/tapestry?

I did try just placing a tapestry under the wallwriting object in ESB, but DSB doesn't render anything else if wallwriting exists on a wall.

What would be the right way to do this? If it's even doable?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Better wall writing...?

Post by Sophia »

It isn't that DSB doesn't render anything if wallwriting exists on a wall, but rather that the DM dungeon sets a compatibility flag in DSB to only render one wallitem per wall. You can turn this off and your background will look right, but there will be graphical glitches elsewhere in the dungeon because the original DM engine worked this way so other mechanics kind of rely on it.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Better wall writing...?

Post by Gambit37 »

Aaahhh. Right. OK, I need to rethink how I do this then. Hmmm.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Better wall writing...?

Post by Gambit37 »

Looks like I can do it using an alternate wall set with the plaque/tapestry pre-composed, and then just paint that wallset onto tiles where there's writing. Bit more fiddly, but it works :)

But I still need to do some tweaks to the writing functions, so I was wondering, can you explain how wallwriting_alter function works? I don't quite follow what it's doing...
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Better wall writing...?

Post by Sophia »

The purpose of wallwriting_alter is to modify the scribbly-looking "distant wallwriting" bitmap so that it looks like an approximation of the actual wall writing. It does this by grabbing the length of each string of the wall writing and drawing rectangles of power pink to cover up the unneeded parts of the image. The coordinates are specified as floating point multipliers instead of as absolute coordinates so that the code will (more or less) work right for any size image and at any level of scaling.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Better wall writing...?

Post by Gambit37 »

OK, thanks. I can't get the results I want with the built in wall-writing renderer, so I'm going to take another approach. Not sure if it'll work but I have some ideas...
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Better wall writing...?

Post by Gambit37 »

So now I'm playing around with the bitmap tweaker. Fun, and confusing times!
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Better wall writing...?

Post by Gambit37 »

With the bitmap tweaker, are there any performance issues I should be aware of? Would it be a problem to use dsb_new_bitmap here?

Also, does the bitmap tweaker get any information about the position that the instance of the arch is currently displayed in? I need to do my own dynamic scaling of the text depending if it's front1, front2, front3 etc but I'm not sure how to check for that...?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Better wall writing...?

Post by Gambit37 »

Not sure you saw my above queries, but not to worry, I've mostly fixed my wallwriting object now:

I have a second wallset with a wallwriting "panel" pre-drawn at every facing. When the wallwriting is spawned, it calls a function to change the wallset at the object location to the alternate pre-drawn panelled wallset. Works great!

Except, there's one small problem remaining: how do I also change the wallset when wallwriting is triggered between active/inactive?

I tried using the same function in the on_trigger property but nothing happens. So things like the "this wall says nothing" and "you will regret that" in DM don't work, because the panel doesn't disappear when the wallwriting is inactive.

Here's the function:

Code: Select all

obj.wallwriting.on_spawn = function(arch, id, lev, x, y, d)
	if (not exvar[id] or not exvar[id].text) then return false end
	local inactive = dsb_get_gfxflag(id, GF_INACTIVE)
	if (inactive) then
		dsb_alt_wallset(wallset.default, lev, x, y, d)
	else
		dsb_alt_wallset(wallset.wallwriting, lev, x, y, d)
	end
end
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Better wall writing...?

Post by Sophia »

Sorry, I missed the questions above. I'm glad you got it working.

The issue is that on_trigger is called by the engine when the party steps on a square or when you drop an item there. It's for handling pressure pads and teleporters and things like that. If you're activating and deactivating wallwriting, then you're handling messages, so you probably want to define a custom message handler that toggles the wallset and put it in obj.wallwriting.msg_handler.

Something like this
(Not tested, so check for typos if it doesn't work)

Code: Select all

function enable_wallwriting(id)
   local lev, x, y, d = dsb_get_coords(id)
   object_enable(id)
   dsb_alt_wallset(wallset.wallwriting, lev, x, y, d)
end

function disable_wallwriting(id)
   local lev, x, y, d = dsb_get_coords(id)
   object_disable(id)
   dsb_alt_wallset(wallset.default, lev, x, y, d)
end

function toggle_wallwriting(id)
   local lev, x, y, d = dsb_get_coords(id)
   object_toggle(id)
   if (dsb_get_gfxflag(id, GF_INACTIVE)) then
      dsb_alt_wallset(wallset.default, lev, x, y, d)
   else
      dsb_alt_wallset(wallset.wallwriting, lev, x, y, d)
   end
end

wallwriting_msg_handler = {
    [M_ACTIVATE] = "enable_wallwriting",
    [M_DEACTIVATE] = "disable_wallwriting",
    [M_TOGGLE] = "toggle_wallwriting"
}
You'll need to add obj.wallwriting.msg_handler = wallwriting_msg_handler to your objects.lua of course.

I hope this helps. There are some other good examples of how to set up a message handler in base/msg_handlers.lua
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Better wall writing...?

Post by Gambit37 »

Ah, Messages! The one part of DSB I've avoided so far, despite knowing that it's core and powerful... Thanks for this, I'll explore it as a solution.

Is there any trick to understanding the messaging system? I seem to struggle with abstract systems like this. It's why I'll never be a hardcore programmer and am content to just do simple loops and basic logic :)

(Oh, by the way, elsewhere I mentioned I was using combined front/side views for some of my wall graphics. I had to revert to the normal DSB wall graphics with all the individual pieces, because the combined graphics totally messed up alternate wallsets which I'd forgotten about...)
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Better wall writing...?

Post by Sophia »

As you probably already understand, a message is just how one inst can send information or commands to another inst. For example, a button telling a door to open, or a pressure pad telling a monster generator to generate some monsters, or whatever. A "message" is really just a set of integers: a message code (e.g., activate, deactivate, etc.) and some data, like the target inst or whatever. A message handler is just a set of Lua functions that get called in response to certain messages with the data passed as parameters to the function.

The simplest trick to understanding how this works is probably looking at the function_caller archetype, because that exposes the basic core of the messaging system directly to the designer. You specify the name of a function to be called in response to certain messages and it just calls the function directly.
Post Reply