init.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. if not minetest.global_exists("switching_station") then switching_station = {} end
  2. switching_station.modpath = minetest.get_modpath("switching_station")
  3. dofile(switching_station.modpath .. "/shared.lua")
  4. if not switching_station.run_once then
  5. for k, v in ipairs({
  6. {tier="hv", name="High-Voltage"},
  7. {tier="mv", name="Medium-Voltage"},
  8. {tier="lv", name="Low-Voltage"},
  9. }) do
  10. -- Which function table are we operating on?
  11. local functable = _G["switching_station_" .. v.tier]
  12. minetest.register_node("switching_station:" .. v.tier, {
  13. description = v.name .. " Cable Box",
  14. tiles = {"switching_station_" .. v.tier .. ".png"},
  15. groups = utility.dig_groups("machine", {
  16. immovable = 1,
  17. ["tier_" .. v.tier] = 1,
  18. }),
  19. drop = "stat2:" .. v.tier,
  20. paramtype2 = "facedir",
  21. on_rotate = function(...) return screwdriver.rotate_simple(...) end,
  22. is_ground_content = false,
  23. sounds = default.node_sound_metal_defaults(),
  24. on_punch = function(...)
  25. return functable.on_punch(...) end,
  26. can_dig = function(...)
  27. return functable.can_dig(...) end,
  28. on_timer = function(...)
  29. return functable.on_timer(...) end,
  30. on_construct = function(...)
  31. return functable.on_construct(...) end,
  32. after_place_node = function(...)
  33. return functable.after_place_node(...) end,
  34. on_metadata_inventory_move = function(...)
  35. return functable.on_metadata_inventory_move(...) end,
  36. on_metadata_inventory_put = function(...)
  37. return functable.on_metadata_inventory_put(...) end,
  38. on_metadata_inventory_take = function(...)
  39. return functable.on_metadata_inventory_take(...) end,
  40. on_blast = function(...)
  41. return functable.on_blast(...) end,
  42. on_destruct = function(...)
  43. return functable.on_destruct(...) end,
  44. allow_metadata_inventory_put = function(...)
  45. return functable.allow_metadata_inventory_put(...) end,
  46. allow_metadata_inventory_move = function(...)
  47. return functable.allow_metadata_inventory_move(...) end,
  48. allow_metadata_inventory_take = function(...)
  49. return functable.allow_metadata_inventory_take(...) end,
  50. on_machine_execute = function(...)
  51. return functable.on_machine_execute(...) end,
  52. })
  53. end
  54. minetest.register_alias("switching_station:switching_station", "switching_station:hv")
  55. for k, v in ipairs({
  56. {chest="chests:chest_public_closed"},
  57. {chest="morechests:woodchest_public_closed"},
  58. }) do
  59. minetest.register_craft({
  60. output = "stat2:lv",
  61. recipe = {
  62. {'plastic:plastic_sheeting', 'cb2:lv', 'plastic:plastic_sheeting'},
  63. {'plastic:plastic_sheeting', v.chest, 'plastic:plastic_sheeting'},
  64. {'plastic:plastic_sheeting', 'cb2:lv', 'plastic:plastic_sheeting'},
  65. },
  66. })
  67. end
  68. minetest.register_craft({
  69. output = "stat2:mv",
  70. recipe = {
  71. {'plastic:plastic_sheeting', 'cb2:mv', 'plastic:plastic_sheeting'},
  72. {'plastic:plastic_sheeting', 'stat2:lv', 'plastic:plastic_sheeting'},
  73. {'plastic:plastic_sheeting', 'cb2:mv', 'plastic:plastic_sheeting'},
  74. },
  75. })
  76. minetest.register_craft({
  77. output = "stat2:hv",
  78. recipe = {
  79. {'plastic:plastic_sheeting', 'cb2:hv', 'plastic:plastic_sheeting'},
  80. {'plastic:plastic_sheeting', 'stat2:mv', 'plastic:plastic_sheeting'},
  81. {'plastic:plastic_sheeting', 'cb2:hv', 'plastic:plastic_sheeting'},
  82. },
  83. })
  84. local c = "switching_station:core"
  85. local f = switching_station.modpath .. "/init.lua"
  86. reload.register_file(c, f, false)
  87. dofile(switching_station.modpath .. "/stat2.lua")
  88. switching_station.run_once = true
  89. end