123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- --[[
- k_smallblocks is a Minetest mod that adds smaller blocks to minetest aswell as
- its own node placement prediction/system
- Copyright (C) 2019 Kurtzmusch
- This file is part of k_smallblocks
- k_smallblocks is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 2.1 of the License, or (at your option) any
- later version.
- k_smallblocks is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License along
- with k_smallblocks. If not, see <https://www.gnu.org/licenses/>.
- --]]
- nodeboxes = {}
- smallblocks.nodeboxes = nodeboxes
- local function box_from_point( point )
-
- local nodebox = { point.x, point.y, point.z, point.x+0.5, point.y+0.5, point.z+0.5 }
- return nodebox
- end
- for key_int, val_bitmap_as_int in pairs(smallblocks.origin_bitmaps) do
- local bitmap = util.integer_to_bitmap( val_bitmap_as_int )
- local bitmap_as_array = util.bitmap_to_array3d( bitmap )
- local index = 1
- local max_index = 1
- nodeboxes[key_int] = {}
- minetest.log("none", "generating nodebox for ".. key_int.. ">>".. val_bitmap_as_int )
- local gen_string = ""
- local bitmap_string = ""
- for ix = 0, max_index, 1 do
- for iy = 0, max_index, 1 do
- for iz = 0, max_index, 1 do
- bitmap_string = bitmap_string .. bitmap_as_array[ix][iy][iz]
- if( bitmap_as_array[ix][iy][iz] == 1) then
- nodeboxes[key_int][index] = box_from_point( { x=ix/2-0.5, y=iy/2-0.5, z=iz/2-0.5} )
- index = index + 1
- gen_string = gen_string .."{"
- for k, v in pairs(nodeboxes[key_int][index-1]) do
- gen_string = gen_string..v..", "
- end
- gen_string = gen_string .."} "
- end
- end
- end
- end
-
- minetest.log("none", bitmap_string)
- minetest.log("none", gen_string )
- end
|