init.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. minetest.register_node("plasticbox:plasticbox", {
  2. description = "Plastic Box",
  3. tiles = {"plasticbox_white.png"},
  4. is_ground_content = false,
  5. groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1, ud_param2_colorable = 1},
  6. sounds = default.node_sound_stone_defaults(),
  7. paramtype2 = "color",
  8. palette = "unifieddyes_palette_extended.png",
  9. on_construct = unifieddyes.on_construct,
  10. on_dig = unifieddyes.on_dig,
  11. })
  12. if minetest.global_exists("stairsplus") then
  13. stairsplus:register_all("plasticbox", "plasticbox", "plasticbox:plasticbox", {
  14. description = "Plastic",
  15. tiles = {"plasticbox_white.png"},
  16. groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1},
  17. sounds = default.node_sound_stone_defaults(),
  18. })
  19. end
  20. minetest.register_craft( {
  21. output = "plasticbox:plasticbox 4",
  22. recipe = {
  23. { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
  24. { "basic_materials:plastic_sheet", "", "basic_materials:plastic_sheet" },
  25. { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
  26. },
  27. })
  28. unifieddyes.register_color_craft({
  29. output = "plasticbox:plasticbox 4",
  30. palette = "extended",
  31. neutral_node = "basic_materials:plastic_sheet",
  32. recipe = {
  33. { "NEUTRAL_NODE", "NEUTRAL_NODE", "NEUTRAL_NODE" },
  34. { "NEUTRAL_NODE", "MAIN_DYE", "NEUTRAL_NODE" },
  35. { "NEUTRAL_NODE", "NEUTRAL_NODE", "NEUTRAL_NODE" },
  36. }
  37. })
  38. unifieddyes.register_color_craft({
  39. output = "plasticbox:plasticbox",
  40. palette = "extended",
  41. type = "shapeless",
  42. neutral_node = "plasticbox:plasticbox",
  43. recipe = {
  44. "NEUTRAL_NODE",
  45. "MAIN_DYE"
  46. }
  47. })
  48. minetest.register_lbm({
  49. name = "plasticbox:convert_colors",
  50. label = "Convert plastic boxes to use param2 color",
  51. nodenames = {
  52. "plasticbox:plasticbox_black",
  53. "plasticbox:plasticbox_blue",
  54. "plasticbox:plasticbox_brown",
  55. "plasticbox:plasticbox_cyan",
  56. "plasticbox:plasticbox_green",
  57. "plasticbox:plasticbox_grey",
  58. "plasticbox:plasticbox_magenta",
  59. "plasticbox:plasticbox_orange",
  60. "plasticbox:plasticbox_pink",
  61. "plasticbox:plasticbox_red",
  62. "plasticbox:plasticbox_violet",
  63. "plasticbox:plasticbox_white",
  64. "plasticbox:plasticbox_yellow",
  65. "plasticbox:plasticbox_darkgreen",
  66. "plasticbox:plasticbox_darkgrey",
  67. },
  68. action = function(pos,node)
  69. local conv = {
  70. ["black"] = 5,
  71. ["blue"] = 73,
  72. ["brown"] = 22,
  73. ["cyan"] = 57,
  74. ["green"] = 41,
  75. ["grey"] = 3,
  76. ["magenta"] = 89,
  77. ["orange"] = 17,
  78. ["pink"] = 11,
  79. ["red"] = 9,
  80. ["violet"] = 81,
  81. ["white"] = 1,
  82. ["yellow"] = 25,
  83. ["darkgreen"] = 46,
  84. ["darkgrey"] = 4,
  85. }
  86. local name = node.name
  87. local oldcolor = string.sub(name,string.len("plasticbox:plasticbox_-"),-1)
  88. node.name = "plasticbox:plasticbox"
  89. if conv[oldcolor] then node.param2 = conv[oldcolor] end
  90. minetest.set_node(pos,node)
  91. end,
  92. })