Page 1 of 1

[solved]beds.bed api top/bottom

PostPosted: Wed Jul 24, 2019 06:38
by Nordal
The Minetest Game API contains a beds API. Thought this to be a simple means to make a bed.
Unfortunately I don't understand the definition part:
Code: Select all
### Bed definition

   {
      description = "Simple Bed",
      inventory_image = "beds_bed.png",
      wield_image = "beds_bed.png",
      tiles = {
         bottom = {'Tile definition'}, -- the tiles of the bottom part of the bed.
         top = {Tile definition} -- the tiles of the bottom part of the bed.
      },
      nodebox = {
         bottom = 'regular nodebox',     -- bottom part of bed (see [Node boxes])
         top = 'regular nodebox',        -- top part of bed (see [Node boxes])
      },
      selectionbox = 'regular nodebox',  -- for both nodeboxes (see [Node boxes])
      recipe = {                                         -- Craft recipe
         {"group:wool", "group:wool", "group:wool"},
         {"group:wood", "group:wood", "group:wood"}
      }
   }

What is the difference between inventory image and wield image?
What do bottom and top of the bed mean? Where is the boundary between top and bottom? What means Tile definition in this context?

Re: beds.bed api top/bottom

PostPosted: Wed Jul 24, 2019 07:06
by TumeniNodes
All of the defs are found in the 'beds.lua' https://github.com/minetest/minetest_ga ... ds.lua#L52

then, if you look within the textures folder for the beds mod, it should become clear.
The small beds_bed.png image is used for both the inventory image (which shows in the hud bar) and the wield image shown in the hand when selected
*and this should help to understand where some of those textures are flipped or rotated, which reduces the number of textures required: https://rubenwardy.com/minetest_modding ... transformt

The simple beds are made up from 2 separate nodeboxes

The api really should provide a comment for this reference

Re: beds.bed api top/bottom

PostPosted: Wed Jul 24, 2019 17:57
by Nordal
Thank you TumeniNodes for your explanation and the valuable hints to the defs and the textures!

Re: beds.bed api top/bottom

PostPosted: Thu Aug 15, 2019 04:30
by Nordal
I now defined a bed completely, but I have problems with the inventory image and the wielded image. They are shown as a colored square. The error is
Code: Select all
2019-08-15 06:21:25: ERROR[Main]: generateImage(): Could not load image "beds_bunkbed_sides32x16.png" while building texture; Creating a dummy image
2019-08-15 06:21:25: ERROR[Main]: generateImage(): Could not load image "beds_bunkbed_sides32x16.png" while building texture; Creating a dummy image

I suppose it's the image size on the one hand. How to make a 16x16 image if the bed's 32 long?
Secondly I don't know how to produce an image with that typical 3D inventory view out of 2D tile images.
Can someone help, please?
https://github.com/Nordall/darkageobjects/tree/master

Re: beds.bed api top/bottom

PostPosted: Thu Aug 15, 2019 05:06
by TumeniNodes
I'll help you but won't be until later in eve.
Basically, you will open a new texture in an image editor such as Gimp, make it 16x16 with transparent background, and then create the image within that space.

I cannot promise that bunk beds will look very good in that space but, I'll give it a shot.

Re: beds.bed api top/bottom

PostPosted: Thu Aug 15, 2019 06:02
by TumeniNodes

Re: beds.bed api top/bottom

PostPosted: Thu Sep 05, 2019 19:08
by Nordal
Hello TumeniNodes,
I went on commenting in issue#2. https://github.com/Nordall/darkageobjects/issues/2. May you want to take a look at it. In short here: bed works fine, only top and bottom are exchanged and the inv image is missing. I'll try this later on.

Re: beds.bed api top/bottom

PostPosted: Sun Sep 08, 2019 15:56
by Nordal
I managed to draw an acceptable inv image!

Thank you very much, TumeniNodes, for your patience and friendliness. I've learned a lot, and without your help this bed would never have been existed.