1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- print("forumbug loading")
- local groups = {choppy=2, dig_immediate=3, picture=1}
- -- Texture for the frame
- local frame_texture = "metal_1.png"
- -- Pixel size of the resulting texture for the node. Higher resolutions for more details.
- local resulttexture_pix = 800
- -- Frame border width in percent
- local frame_widthpercent = 2.5
- -- Scaling of the picture
- local pic_scale = 2.5
- -- Get the width and height of the picture from the file in pixel
- local pic_pixwidth,pic_pixheight=32,24
- -- Get the max side lenght of the picture in pixel
- local pic_pixmax = math.max(pic_pixwidth,pic_pixheight)
- -- Frame border width in pixel
- local frame_widthpixel = math.ceil(frame_widthpercent * pic_pixmax / 100.0)
- -- Distance beetween the frame and the picture in pixel
- local border_pix = 4
- -- Pixel size of the combined square texture of the picture with frame and border
- local pictexture_pix = pic_pixmax + (frame_widthpixel * 2) + (border_pix * 2)
- -- X and Y position oft the picture in the combined square texture of the picture with frame and border
- local pic_xoffset = ((pic_pixmax - pic_pixwidth) / 2) + frame_widthpixel + border_pix
- local pic_yoffset = ((pic_pixmax - pic_pixheight) / 2) + frame_widthpixel + border_pix
- -- Frame border width of the node
- local frame_widthnode = 1.0 / pictexture_pix * frame_widthpixel
- -- Frame border thickness of the node
- local frame_thickness = 0.1
- -- Picture width of the node (whole picture including frame)
- local pic_width = 1.0
- -- Picture height of the node (whole picture including frame)
- local pic_height = 1.0
- -- Picture thickness of the node
- local pic_thickness = 0.05
- if pic_pixwidth > pic_pixheight then
- -- Landscape picture. Set the Picture height of the node (whole picture including frame) accordingly to the original picture aspect ratio
- pic_height = (pic_width / pictexture_pix) * (pic_pixheight + 2 * (frame_widthpixel + border_pix))
- else
- -- Potrait picture Set the Picture width of the node (whole picture including frame) accordingly to the original picture aspect ratio
- pic_width = (pic_height / pictexture_pix) * (pic_pixwidth + 2 * (frame_widthpixel + border_pix))
- end
- -- node
- minetest.register_node(":bughunt:bug", {
- description = "Picture #1",
- drawtype = "nodebox",
- -- Tile definition in the follwing order: +Y, -Y, +X, -X, +Z, -Z.
- tiles = {
- {name="("..frame_texture.."^[resize:"..resulttexture_pix.."x"..resulttexture_pix..")^([combine:"..pictexture_pix.."x"..pictexture_pix..":"..pic_xoffset..","..pic_yoffset.."=picture_1.png^[resize:"..resulttexture_pix.."x"..resulttexture_pix..")"},
- {name=frame_texture}
- },
- visual_scale = pic_scale,
- inventory_image = "gallery_inventory.png",
- wield_image = "gallery_inventory.png",
- paramtype = "light",
- paramtype2 = "wallmounted",
- sunlight_propagates = true,
- walkable = false,
- node_box = {
- type = "fixed",
- -- Box definition in following order: {x1, y1, z1, x2, y2, z2}
- fixed = {
- -- Picture
- {-pic_width/2.0, -0.5/pic_scale, -pic_height/2.0, pic_width/2.0, -(0.5 - pic_thickness) / pic_scale, pic_height/2.0},
- -- Left frame border
- {-pic_width/2.0, -0.5/pic_scale, -pic_height/2.0, -pic_width/2.0+frame_widthnode, -(0.5 - frame_thickness) / pic_scale, pic_height/2.0},
- -- Right frame border
- {pic_width/2.0-frame_widthnode, -0.5/pic_scale, -pic_height/2.0, pic_width/2.0, -(0.5 - frame_thickness) / pic_scale, pic_height/2.0},
- -- Bottom frame border
- {-pic_width/2.0, -0.5/pic_scale, -pic_height/2.0, pic_width/2.0, -(0.5 - frame_thickness) / pic_scale, -pic_height/2.0+frame_widthnode},
- -- Top frame border
- {-pic_width/2.0, -0.5/pic_scale, pic_height/2.0-frame_widthnode, pic_width/2.0, -(0.5 - frame_thickness) / pic_scale, pic_height/2.0},
- },
- },
- groups = groups,
- })
|