generate_map.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. --[[
  2. k_smallblocks is a Minetest mod that adds smaller blocks to minetest aswell as
  3. its own node placement prediction/system
  4. Copyright (C) 2019 Kurtzmusch
  5. This file is part of k_smallblocks
  6. k_smallblocks is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU Lesser General Public License as published by the Free
  8. Software Foundation; either version 2.1 of the License, or (at your option) any
  9. later version.
  10. k_smallblocks is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12. PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License along
  14. with k_smallblocks. If not, see <https://www.gnu.org/licenses/>.
  15. --]]
  16. for key_int, val_bitmap_as_int in pairs( smallblocks.origin_bitmaps ) do
  17. local bitmap_as_int = val_bitmap_as_int
  18. local bitmap = util.integer_to_bitmap( bitmap_as_int )
  19. local rotated_bitmap = bitmap
  20. local facedir = 0
  21. -- rotations around +y
  22. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  23. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  24. facedir = facedir + 1
  25. for i = 1, 3, 1 do
  26. rotated_bitmap = util.rotate_bitmap_around_plus_y( rotated_bitmap )
  27. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  28. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  29. facedir = facedir + 1
  30. end
  31. rotated_bitmap = util.orient_bitmap_towards_plus_z( bitmap )
  32. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  33. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  34. facedir = facedir + 1
  35. for i = 1, 3, 1 do
  36. rotated_bitmap = util.rotate_bitmap_around_plus_z( rotated_bitmap )
  37. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  38. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  39. facedir = facedir + 1
  40. end
  41. rotated_bitmap = util.orient_bitmap_towards_minus_z( bitmap )
  42. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  43. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  44. facedir = facedir + 1
  45. for i = 1, 3, 1 do
  46. rotated_bitmap = util.rotate_bitmap_around_minus_z( rotated_bitmap )
  47. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  48. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  49. facedir = facedir + 1
  50. end
  51. rotated_bitmap = util.orient_bitmap_towards_plus_x( bitmap )
  52. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  53. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  54. facedir = facedir + 1
  55. for i = 1, 3, 1 do
  56. rotated_bitmap = util.rotate_bitmap_around_plus_x( rotated_bitmap )
  57. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  58. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  59. facedir = facedir + 1
  60. end
  61. rotated_bitmap = util.orient_bitmap_towards_minus_x( bitmap )
  62. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  63. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  64. facedir = facedir + 1
  65. for i = 1, 3, 1 do
  66. rotated_bitmap = util.rotate_bitmap_around_minus_x( rotated_bitmap )
  67. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  68. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  69. facedir = facedir + 1
  70. end
  71. rotated_bitmap = util.orient_bitmap_towards_minus_y( bitmap )
  72. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  73. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  74. facedir = facedir + 1
  75. for i = 1, 3, 1 do
  76. rotated_bitmap = util.rotate_bitmap_around_minus_y( rotated_bitmap )
  77. smallblocks.int_facedir_map[util.bitmap_to_integer( rotated_bitmap )] = facedir
  78. smallblocks.int_name_map[util.bitmap_to_integer( rotated_bitmap )] = ""..bitmap_as_int
  79. facedir = facedir + 1
  80. end
  81. end
  82. for i = 1, 255, 1 do
  83. minetest.log( "none", i.." maps to " .. smallblocks.int_name_map[i] .. " facedir:" .. smallblocks.int_facedir_map[i] )
  84. end
  85. local test_bitmap_plus_y = util.integer_to_bitmap( 1 )
  86. local test_bitmap = test_bitmap_plus_y
  87. test_bitmap = util.orient_bitmap_towards_minus_x( test_bitmap_plus_y )
  88. minetest.log( "error", "tb-x" .. util.bitmap_to_integer( test_bitmap ) )
  89. test_bitmap = util.orient_bitmap_towards_plus_x( test_bitmap_plus_y )
  90. minetest.log( "error", "tb+x" .. util.bitmap_to_integer( test_bitmap ) )
  91. test_bitmap = util.orient_bitmap_towards_minus_z( test_bitmap_plus_y )
  92. minetest.log( "error", "tb-z" .. util.bitmap_to_integer( test_bitmap ) )
  93. test_bitmap = util.orient_bitmap_towards_plus_z( test_bitmap_plus_y )
  94. minetest.log( "error", "tb+z" .. util.bitmap_to_integer( test_bitmap ) )