Creating new objects
Moderator: Sophia
Forum rules
Please read the Forum rules and policies before posting.
Please read the Forum rules and policies before posting.
- ebeneezergude
- Expert
- Posts: 345
- Joined: Mon Jan 21, 2013 10:58 pm
- Location: I see walls stretching off into the darkness...
Creating new objects
So am now getting into proper tinkering with DSB to assess if it's the way to go for my dungeon - and it's looking tempting as adding/changing graphics seems a doddle. Having read the tutorials, I am not quite sure I understand the relationship between duplicating an object arch type to create a new object, replacing it's btmaps graphics with a new custom bitmaps, and then giving it a new icon. The icongrid.pcx file - how does that work? Do I need to enlarge it to create a new icon for a new object? Or do I not need to use it, can I create a 'one off' icon graphic called by the new object code, and store that graphic somewhere? Where would that best be placed? Am essentially testing a fully new object based on say, a key. I want a new icon and a new bitmap. Thanks in advance!
- Sophia
- Concise and Honest
- Posts: 4239
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Creating new objects
You don't need to add to the icongrid if you don't want to. It's certainly possible (and, as long as you're not adding a ton of new objects, easier!) to just use a single bitmap as an icon, like RTC does.
Here is a tutorial for adding custom objects (the second half of the post)
http://www.dungeon-master.com/forum/vie ... 53&t=28988
Here is a tutorial for adding custom objects (the second half of the post)
http://www.dungeon-master.com/forum/vie ... 53&t=28988
- ebeneezergude
- Expert
- Posts: 345
- Joined: Mon Jan 21, 2013 10:58 pm
- Location: I see walls stretching off into the darkness...
Re: Creating new objects
Thanks. OK, have now found some useful info in the graphics.lua and the dsb pages on dungeon master wiki (wow... didn't know these existed!). So icon grid number seems to be determined by the number of pxiels along a 16 column, 32x32 pixel-tiled file - ie 512 in width. Can this bitmap be extended vertically, arbitrarily by 32 pixels at a time? Is that what you mean by "it's certainly possible"? Can I keep adding 32 pixels to the vertical pixel dimension?
Still can't quite work out how to reference an individual bitmap for one icon only... but will keep digging!
EDIT: I guess I need to know what to write for Icon =
Still can't quite work out how to reference an individual bitmap for one icon only... but will keep digging!
EDIT: I guess I need to know what to write for Icon =
- ebeneezergude
- Expert
- Posts: 345
- Joined: Mon Jan 21, 2013 10:58 pm
- Location: I see walls stretching off into the darkness...
Re: Creating new objects
Actually, have managed it. I've created a test object of the consumable type with separate object and icon bitmaps.
Here's my graphics.lua file:
gfx.test_object = dsb_get_bitmap("test_object")
gfx.test_object_full = dsb_get_bitmap("test_object_full")
...first line is the bitmap for the icon, second line is the bitmap for the 'full' bitmap of the object in the viewport.
Here's my objects.lua:
...where I've made a consumable test object (based on an apple).
So, both object and icon work....phew...!
Here's my graphics.lua file:
gfx.test_object = dsb_get_bitmap("test_object")
gfx.test_object_full = dsb_get_bitmap("test_object_full")
...first line is the bitmap for the icon, second line is the bitmap for the 'full' bitmap of the object in the viewport.
Here's my objects.lua:
Code: Select all
obj.test_object = {
name="TEST OBJECT",
type="THING",
shortdesc="CONSUMABLE",
class="FOOD",
mass=4,
icon=gfx.test_object,
dungeon=gfx.test_object_full,
foodval=500,
fit_pouch = true,
on_consume=eatdrink
}
So, both object and icon work....phew...!
Last edited by ebeneezergude on Sun Feb 03, 2013 9:10 pm, edited 1 time in total.
- ebeneezergude
- Expert
- Posts: 345
- Joined: Mon Jan 21, 2013 10:58 pm
- Location: I see walls stretching off into the darkness...
Re: Creating new objects
OK, so my next question then - where in the bitmap does it register the 'base' of the bitmap in terms of co-ordinates? The apple.pcx happens to have the apple pixels drawn at the very base of the bitmap. The brickswitch_front.pcx bitmap has the switch pixels drawn at the very top of the bitmap. Button_green_front.pcx has the button pixels drawn in the middle of the bitmap (surrounded by 'powerpink').
If I put the button_green_front.pcx onto an apple object, it would therefore appear to be floating above the floor. How do I know or define what the reference point is for any given bitmap? Ie, where is it's base, or it's centre?
Thanks!
If I put the button_green_front.pcx onto an apple object, it would therefore appear to be floating above the floor. How do I know or define what the reference point is for any given bitmap? Ie, where is it's base, or it's centre?
Thanks!
- Sophia
- Concise and Honest
- Posts: 4239
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Creating new objects
If you're going to paste code, please put it in a block. It makes it much easier to read.
It isn't that you define an absolute position for a bitmap and then the engine always draws it there.
Code: Select all
DSB tries to "just work" with respect to bitmap positioning. The "reference point" for each type of object is slightly different, due to the different positioning that is considered important for each object. So, you're correct, wallitems and doors are positioned according to their absolute center, while items resting on the floor are positioned according to the center of their bottom row. However, this determination is done by object type.ebeneezergude wrote:OK, so my next question then - where in the bitmap does it register the 'base' of the bitmap in terms of co-ordinates? The apple.pcx happens to have the apple pixels drawn at the very base of the bitmap. The brickswitch_front.pcx bitmap has the switch pixels drawn at the very top of the bitmap. Button_green_front.pcx has the button pixels drawn in the middle of the bitmap (surrounded by 'powerpink').
That means this statement isn't true. The button will be placed like any other thing resting on the floor.ebeneezergude wrote:If I put the button_green_front.pcx onto an apple object, it would therefore appear to be floating above the floor. How do I know or define what the reference point is for any given bitmap?
It isn't that you define an absolute position for a bitmap and then the engine always draws it there.
- Gambit37
- Should eat more pies
- Posts: 13714
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Creating new objects
This is what I meant when I said bitmaps in DSB "just work". Most stuff is positioned automatically and you don't need to worry about working out offsets. It's great You can make micro adjustments using various offset properties in the archetype.
- ebeneezergude
- Expert
- Posts: 345
- Joined: Mon Jan 21, 2013 10:58 pm
- Location: I see walls stretching off into the darkness...
- Gambit37
- Should eat more pies
- Posts: 13714
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Creating new objects
I started some pages about objects/archetypes on the DSB Wiki, you might find them useful, although they are still very incomplete:
http://dmwiki.atomas.com/wiki/DSB/Archetypes
http://dmwiki.atomas.com/wiki/DSB/Archetypes/Properties
http://dmwiki.atomas.com/wiki/DSB/Archetypes
http://dmwiki.atomas.com/wiki/DSB/Archetypes/Properties
- ebeneezergude
- Expert
- Posts: 345
- Joined: Mon Jan 21, 2013 10:58 pm
- Location: I see walls stretching off into the darkness...
Re: Creating new objects
Gambit, thanks for the links to your wiki pages, very useful reading.
Sofia, did you have any joy on getting individual icons into ESB? Could it be achieved by implementing a new line of code within an object entry, similar to the one calling in a bespoke bitmap? Ie, something along the lines of:
...thus bypassing the cells.pcx and directly referencing a graphic into the editor. I'm sure it's not as simple as I have made it out to be, but you get the idea!
Sofia, did you have any joy on getting individual icons into ESB? Could it be achieved by implementing a new line of code within an object entry, similar to the one calling in a bespoke bitmap? Ie, something along the lines of:
Code: Select all
icon_ESB=gfx.new_object_editor_icon
- Sophia
- Concise and Honest
- Posts: 4239
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Creating new objects
Yes, that's actually more or less the approach I'd take.
I just haven't gotten around to it yet. It was a somewhat busy week.
I just haven't gotten around to it yet. It was a somewhat busy week.
- ebeneezergude
- Expert
- Posts: 345
- Joined: Mon Jan 21, 2013 10:58 pm
- Location: I see walls stretching off into the darkness...
Re: Creating new objects
Hi Sophia, it certainly was...! Thanks. Presumably the code could also be written with the option to point to a custom cells.pcx?
- ebeneezergude
- Expert
- Posts: 345
- Joined: Mon Jan 21, 2013 10:58 pm
- Location: I see walls stretching off into the darkness...
Re: Creating new objects
How does DSB deal with hidden statistics? Ie, the rabbit foot object from DM. Is Apply_Luck a fixed value? Can you control the value? What other hidden stats are accessible?
Thanks!
Code: Select all
obj.rabbits_foot = {
name="RABBIT'S FOOT",
type="THING",
class="MISC",
mass=1,
icon=gfx.icons[137],
dungeon=gfx.rabbits_foot,
max_throw_power=40,
to_anywhere=apply_luck,
from_anywhere=remove_luck,
fit_pouch=true,
go_thru_bars=true
Thanks!
- Sophia
- Concise and Honest
- Posts: 4239
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Creating new objects
The only hidden stat supported by DSB by default is Luck, but you can add your own stats and other information through the use of character exvars (the ch_exvar table).
You can change the value used by apply_luck simply by editing the function itself. It's in base/util.lua, and it also demonstrates the use of ch_exvar.
You can change the value used by apply_luck simply by editing the function itself. It's in base/util.lua, and it also demonstrates the use of ch_exvar.