init.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. --[[
  2. More Blocks: Stairs+
  3. Copyright (c) 2011-2017 Hugo Locurcio and contributors.
  4. Licensed under the zlib license. See LICENSE.md for more information.
  5. --]]
  6. -- Nodes will be called <modname>:{stair,slab,panel,micro}_<subname>
  7. local modpath = minetest.get_modpath("moreblocks").. "/stairsplus"
  8. stairsplus = {}
  9. stairsplus.expect_infinite_stacks = false
  10. stairsplus.shapes_list = {}
  11. if not minetest.get_modpath("unified_inventory")
  12. and minetest.settings:get_bool("creative_mode") then
  13. stairsplus.expect_infinite_stacks = true
  14. end
  15. function stairsplus.copytable(orig)
  16. local orig_type = type(orig)
  17. local copy
  18. if orig_type == 'table' then
  19. copy = {}
  20. for orig_key, orig_value in next, orig, nil do
  21. copy[stairsplus.copytable(orig_key)] = stairsplus.copytable(orig_value)
  22. end
  23. setmetatable(copy, stairsplus.copytable(getmetatable(orig)))
  24. else
  25. copy = orig
  26. end
  27. return copy
  28. end
  29. function stairsplus:prepare_groups(groups)
  30. local result = {}
  31. if groups then
  32. for k, v in pairs(groups) do
  33. if k ~= "wood" and k ~= "stone" then
  34. result[k] = v
  35. end
  36. end
  37. end
  38. if not moreblocks.config.stairsplus_in_creative_inventory then
  39. result.not_in_creative_inventory = 1
  40. end
  41. return result
  42. end
  43. function stairsplus:register_all(modname, subname, recipeitem, fields)
  44. self:register_stair(modname, subname, recipeitem, fields)
  45. self:register_slab (modname, subname, recipeitem, fields)
  46. self:register_slope(modname, subname, recipeitem, fields)
  47. self:register_panel(modname, subname, recipeitem, fields)
  48. self:register_micro(modname, subname, recipeitem, fields)
  49. -- self:register_6dfacedir_conversion(modname, subname) -- Not needed as of Q3 2013, uncomment to fix old maps.
  50. end
  51. function stairsplus:register_alias_all(modname_old, subname_old, modname_new, subname_new)
  52. self:register_stair_alias(modname_old, subname_old, modname_new, subname_new)
  53. self:register_slab_alias(modname_old, subname_old, modname_new, subname_new)
  54. self:register_slope_alias(modname_old, subname_old, modname_new, subname_new)
  55. self:register_panel_alias(modname_old, subname_old, modname_new, subname_new)
  56. self:register_micro_alias(modname_old, subname_old, modname_new, subname_new)
  57. end
  58. function stairsplus:register_alias_force_all(modname_old, subname_old, modname_new, subname_new)
  59. self:register_stair_alias_force(modname_old, subname_old, modname_new, subname_new)
  60. self:register_slab_alias_force(modname_old, subname_old, modname_new, subname_new)
  61. self:register_slope_alias_force(modname_old, subname_old, modname_new, subname_new)
  62. self:register_panel_alias_force(modname_old, subname_old, modname_new, subname_new)
  63. self:register_micro_alias_force(modname_old, subname_old, modname_new, subname_new)
  64. end
  65. function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light)
  66. stairsplus:register_all(modname, subname, recipeitem, {
  67. groups = groups,
  68. tiles = images,
  69. description = description,
  70. drop = drop,
  71. light_source = light
  72. })
  73. end
  74. -- dofile(modpath.. "/aliases.lua") -- Not needed as of Q2 2013, uncomment to fix old maps.
  75. -- dofile(modpath.. "/conversion.lua") -- Not needed as of Q2 2013, uncomment to fix old maps.
  76. dofile(modpath .. "/stairs.lua")
  77. dofile(modpath .. "/slabs.lua")
  78. dofile(modpath .. "/slopes.lua")
  79. dofile(modpath .. "/panels.lua")
  80. dofile(modpath .. "/microblocks.lua")
  81. dofile(modpath .. "/registrations.lua")