Questions about DSB/ESB

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.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

You can always use dsb_bitmap_textout(bitmap, font, string, x, y, alignment, color).

For example:

Code: Select all

dsb_bitmap_textout(bmp, sys_font, "HELLO THERE", 0, 0, LEFT, {255, 255, 255})
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

OK, thanks. I found something else: in the Wiki, the description of dsb_add_champion doesn't seem to match what's generated in the dungeon.lua file? Parameters are slightly different?

Also, what's the right way to get the portrait value for a given champion ID? That is, what's the nature of the champions table array and how can I access it?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

Gambit37 wrote:OK, thanks. I found something else: in the Wiki, the description of dsb_add_champion doesn't seem to match what's generated in the dungeon.lua file? Parameters are slightly different?
Yes. In hand-coded files, it's expected that you want DSB to manage the character and inst id numbers and you use symbolic labels. However, ESB already manages the numbers for you, so for ESB output, it's simpler to just explicitly use the numbers ESB is already using than to create some weird (and potentially buggy) infrastructure to translate from ESB id numbers to symbolic labels, which DSB will then just turn back into id numbers when it compiles the dungeon.
Gambit37 wrote:Also, what's the right way to get the portrait value for a given champion ID? That is, what's the nature of the champions table array and how can I access it?
I don't understand the question. If you mean how to how to get a character's portrait in code, there isn't a command for it at the moment, but I will add one.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

Ah, OK. For the "champions table array" I was making a big assumption that there's an array of variables I could access which would include the name of the portrait ;-) For now, I've done it another way, but a specific command for it would be useful :-)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

What's the right way to do a floortext in the party leader's colour?
Or how to do floortexts in an random champions colours, and start it with "{NAME} SAYS: " {message in exvar}
Pretty sure I'd have to write some functions, but asking just in case there's something in there already.... :-)
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

The basic "floortext" arch is really simple. It doesn't support anything like that.
The usual way to do it in Lua code is to do:

Code: Select all

dsb_write(player_colors[1], "THIS WILL BE IN GREEN (OR WHATEVER)")
You can use dsb_rand to generate a random party member, dsb_ppos_char to translate the party position to a character id, and valid_and_alive to verify it's someone who can talk. One small gotcha is that DSB internally notes party positions as 0-3, whereas Lua arrays start at 1 so player_colors starts at 1. (Yes, if I was starting DSB over today, I'd not do that)

This should help: (not tested, so if it doesn't work, let me know)

Code: Select all

function random_valid_party_member()
   local sel
   local ppos = dsb_rand(0, 3)
   local tries = 0
   repeat
      ppos = (ppos + 1) % 4
      sel = dsb_ppos_char(ppos)
      tries = tries + 1
      if (tries > 4) then
         return nil
      end 
   until (valid_and_alive(sel))
   return ppos, sel
end
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

Cool, thanks. I'm not 100% sure about how to set this all up, but I'll give it a go :)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

What happens to a champion removed with dsb_champion_fromparty(ppos)? Where do they go? What happens to their inventory? Can you get them back later?
I'd like to add some party changing mechanics in my adventure, but I'm concerned the player could lose essential items by dismissing a character, and never be able to get them back...
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

The character doesn't go anywhere, really. He or she still exists on the roster, just not in the party any more... just like champions who are in mirrors who are never picked. Items remain with the character, but, of course, you could always write Lua to iterate through the character's possessions and drop them on the ground if this is a problem. There is a function called drop_all_items_and_magicshields found in base/util.lua that will handle that. See sys_character_die in base/system.lua for a usage example.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

Thanks. On second thoughts, maybe there's too much potential here for introducing game breaking situations. I'll leave this feature for now ;-)

Another question: is it possible to move the location of the "item currently in mouse cursor" text? You know, the name of picked up items that appears above the magic runes? I've had some thoughts about changing the magic system and would need a bit more space in the interface to do it... similarly, can I move the attack buttons and arrow controls?
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

^^^ Any thoughts on the above question?

Also, is there a flag to set monsters as passive? I couldn't find one in the base objects.lua? If not, how would you make a monster that doesn't track or attack the party, but just wanders around randomly?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

Gambit37 wrote:is it possible to move the location of the "item currently in mouse cursor" text? You know, the name of picked up items that appears above the magic runes? I've had some thoughts about changing the magic system and would need a bit more space in the interface to do it... similarly, can I move the attack buttons and arrow controls?
As I stated in another thread, it's not currently possible, but it will be included in DSB 0.53. I'll add the ability to move the "item currently held" indicator to the list of things to do.
Gambit37 wrote:is there a flag to set monsters as passive? I couldn't find one in the base objects.lua? If not, how would you make a monster that doesn't track or attack the party, but just wanders around randomly?
There isn't a flag, as such, but the way you'd do it is by setting the monster to use an AI function that was the same as the one monsters use when they are at distance or on a different level... which causes them to just wander around basically randomly.

So, all we have to do to make it work for nearby monsters is just use random_move for their near AI as well.

Code: Select all

obj.passive_monster.ai_near = function (id, sight)
   return random_move(id, false, nil)
end
(The syntax you might be more used to involves defining the function elsewhere, which also works, but this way is smaller for very simple functions)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

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

Re: Questions about DSB/ESB

Post by Gambit37 »

How would I write some text on a wallitem, but only if the party is standing right in front of it? (Like the way a mirror only displays a portrait when you face it straight on the tile in front).
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

I'm not quite sure what you're asking.
It sounds like wallwriting would basically do what you want. You could clone it and change the font and such...?
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

Yeah, sort of like that. But I only want the text to show if the party is standing right in front of it, the way a mirror only shows a portrait at that view. I don't want all the fuzzy text that's displayed at distant or side views... I wasn't sure the way to set that up?
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Re: Questions about DSB/ESB

Post by beowuuf »

Why don't you want the visual clue there's something to see there?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

If you clone wallwriting but set its bitmaps to nil, nothing will show up at a greater distance. However, it will still be drawn close up, because the "WRITING" renderer hack takes care of that. Don't forget to set bitmap_tweaker to false when you clone it-- if you just set it to nil, then you're actually just adding a nil to the table of changes to make to the cloned archetype, and DSB won't detect that you even wanted to do anything.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

beowuuf wrote:Why don't you want the visual clue there's something to see there?
The wallitem graphics that will be displayed will make it obvious there's something to see. But I only want the text to be written ontop of the wallitem at that first position.
Spoiler
Basically, it's a street sign. At distance or from the side, you can't read the text...
@Sophia: OK, I think I can work with that, however I was hoping to keep the wallitem graphics and just write some text on top of it, text that I can pass in an exvar. If I clone walltext and hide the bitmaps, then I'll need to create two wallitems to create this effect which I was trying to avoid. Any suggestions on how to make it all work with one wallitem that has normal images displayed, with text on top?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

The easiest way to do it involves two wallitems. However, you can use an on_spawn to automatically create the second wallitem at runtime, so you only have to worry about a single one in the editor. This is how DSB handles ceiling pits, by the way.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

What's the right way to render an overlay over the dungeon view, eg a water effect, or the front view of a boat that the party can use...?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

Set it up as a condition.

Code: Select all

C_MYCONDITION = dsb_add_condition(PARTY, nil, gfx.overlay_graphic, 0, nil)
Then you can use the following code:

Code: Select all

-- Activates it
dsb_set_condition(PARTY, C_MYCONDITION, 1)
 -- Deactivates it
dsb_set_condition(PARTY, C_MYCONDITION, 0)
Conditions can do a lot more, of course (in the base code, they handle poisoning and magical shields) but this is a simple form that will just display an overlay graphic when desired.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

Nice and easy! Thanks :-)

Another question: Is it possible to store Lua variables in a save game?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

Yes. dsb_export(name_of_variable) will tell DSB to save that variable when the game is saved.

This works for tables and such, too, so it might be simplest to put something like this in your startup code:

Code: Select all

dsb_export("my_global_data")
my_global_data = {
   thing1 = 4,
   thing2 = "some stuff",
   -- etc etc
}
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

So the command just sets up an automatic save of the variables, I don't need to write anything special to make it work on every save?
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

Another question: How do I move the position of the character's name, the three main stats and the load value that's rendered in the inventory? Can't seem to find that in any of the new GUI positioning code?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

Gambit37 wrote:So the command just sets up an automatic save of the variables, I don't need to write anything special to make it work on every save?
As long as you've added the dsb_export command to your startup.lua (or one of the linked files from lua_manifest) it will automatically save whatever you want to export every time you save.
Gambit37 wrote:Another question: How do I move the position of the character's name, the three main stats and the load value that's rendered in the inventory? Can't seem to find that in any of the new GUI positioning code?
Those can't be moved around. (At least not yet!)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

Sophia wrote:Those can't be moved around. (At least not yet!)
Oooh, does this mean that eventually I can? :-) I'm tinkering with a new layout for the inventory, and I've come up with something quite nice, but would need to be able to move those bits too...

EDIT: Also, I can't find how to move the "Poisoned" graphic within the default subrenderer. Looks like a lot of this stuff is not in the base code, but in the core engine? Is it modifiable?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Questions about DSB/ESB

Post by Sophia »

Gambit37 wrote:I can't find how to move the "Poisoned" graphic within the default subrenderer. Looks like a lot of this stuff is not in the base code, but in the core engine? Is it modifiable?
You're correct, the core engine draws condition graphics, which is what poisoning is. However, it is modifiable: the position of this graphic within the subrenderer is set by its x_off and y_off values. Look in base/graphics.lua.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Questions about DSB/ESB

Post by Gambit37 »

Aha, of course! Thanks :-)
OK, next question.... Can the subrenderer size be changed? I can't find width/height for this anywhere -- is it hard-coded? I see that the x,y start position is in inventory_info.lua, but not its size?
Post Reply