init.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. -- bitmaps are a binary representation of which of the 8 divisions of each node are filled by the material
  17. -- origin bitmaps are the ones that can be rotated to make any other of the 255 possibilities
  18. -- many bitmaps can be mapped to a single origin_bitmap, and each origin is a node registration
  19. -- the origin bitmaps are generated by generate_origin_bitmaps.lua
  20. -- 22 bitmaps will be generated and 22 nodes for each material will be registered
  21. -- the mod creates bitmaps when placing nodes over other nodes of the same material,
  22. -- then finds the correct node name and facedir using the maps int_facedir_map and int_name_map
  23. -- all 'unnamed nodes' will be called "<number>_<material>"
  24. -- 'named nodes' are the ones craftable and have a distinc name like "stair_<material>"
  25. -- example of named node "stair_stonebrick"
  26. -- exmaple of unnamed node "127_stonebrick"
  27. -- named nodes apear in the creative inventory and can be crafted
  28. -- unnamed nodes will not drop themselves when dug, but will drop the equivalent amount in smallblock_<material>
  29. -- example: when a cobble inner stair is dug, it will drop 7 smallblock_cobble
  30. -- inner and outer stairs are not craftable, but easily buildable
  31. -- the mod doesnt work with screwdriver, the idea is that you never need to rotate anything because you can manually
  32. -- dig a smallblock out of a node and replace it in other place in that node. textures always lign up aswell
  33. -- definitions of named nodes will contain a recipe, logic for correct orientation when placed and dug
  34. smallblocks = {}
  35. local modpath = minetest.get_modpath("k_smallblocks")
  36. smallblocks.int_facedir_map = { [255]=0 } -- maps an int that represents a bitmap to a facedir
  37. smallblocks.int_name_map = { [255]="" } -- maps an int that represents a bitmap to a name. many ints can map to a single name. a name is a string of the interger that represents the bitmap
  38. -- smallblocks.name_int_map = {} -- inverse of the above map, might be usefull in the future
  39. -- definitions of named (and craftable) nodes
  40. dofile(modpath .. "/util.lua")
  41. dofile(modpath .. "/definitions.lua")
  42. dofile(modpath .. "/generate_shapes.lua")
  43. dofile(modpath .. "/generate_nodeboxes.lua")
  44. dofile(modpath .. "/generate_map.lua")
  45. dofile(modpath .. "/api.lua")
  46. -- smallblocks.name_int_map = util.table_invert( smallblocks.int_name_map )
  47. -- example of how a mod would make smallblocks for a base node
  48. smallblocks.register_node( "stonebrick", true, false )