rails.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. -- Common rail registrations
  2. local regular_rail_itemname = "default:rail"
  3. if minetest.registered_nodes["carts:rail"] then
  4. -- MTG Compatibility
  5. regular_rail_itemname = "carts:rail"
  6. end
  7. boost_cart:register_rail(":"..regular_rail_itemname, {
  8. description = "Rail",
  9. tiles = {
  10. "carts_rail_straight.png", "carts_rail_curved.png",
  11. "carts_rail_t_junction.png", "carts_rail_crossing.png"
  12. },
  13. groups = boost_cart:get_rail_groups()
  14. })
  15. --[[
  16. -- Moreores' copper rail
  17. local copperrail_registered = false
  18. if minetest.get_modpath("moreores") then
  19. minetest.register_alias("carts:copperrail", "moreores:copper_rail")
  20. local raildef = minetest.registered_nodes["moreores:copper_rail"]
  21. if raildef and minetest.raillike_group then
  22. -- Ensure that this rail uses the same connect_to_raillike
  23. raildef.groups.connect_to_raillike = minetest.raillike_group("rail")
  24. minetest.override_item("moreores:copper_rail", {
  25. groups = raildef.groups
  26. })
  27. copperrail_registered = true
  28. end
  29. end
  30. if not copperrail_registered then
  31. boost_cart:register_rail(":carts:copperrail", {
  32. description = "Copper rail",
  33. tiles = {
  34. "carts_rail_straight_cp.png", "carts_rail_curved_cp.png",
  35. "carts_rail_t_junction_cp.png", "carts_rail_crossing_cp.png"
  36. },
  37. groups = boost_cart:get_rail_groups()
  38. })
  39. minetest.register_craft({
  40. output = "carts:copperrail 12",
  41. recipe = {
  42. {"default:copper_ingot", "", "default:copper_ingot"},
  43. {"default:copper_ingot", "group:stick", "default:copper_ingot"},
  44. {"default:copper_ingot", "", "default:copper_ingot"},
  45. }
  46. })
  47. end
  48. ]]
  49. -- Power rail
  50. boost_cart:register_rail(":carts:powerrail", {
  51. description = "Powered rail",
  52. tiles = {
  53. "carts_rail_straight_pwr.png", "carts_rail_curved_pwr.png",
  54. "carts_rail_t_junction_pwr.png", "carts_rail_crossing_pwr.png"
  55. },
  56. groups = boost_cart:get_rail_groups(),
  57. after_place_node = function(pos, placer, itemstack)
  58. if not mesecon then
  59. minetest.get_meta(pos):set_string("cart_acceleration", "0.5")
  60. end
  61. end,
  62. mesecons = {
  63. effector = {
  64. action_on = function(pos, node)
  65. boost_cart:boost_rail(pos, 0.5)
  66. end,
  67. action_off = function(pos, node)
  68. minetest.get_meta(pos):set_string("cart_acceleration", "0")
  69. end,
  70. },
  71. },
  72. })
  73. minetest.register_craft({
  74. output = "carts:powerrail 6",
  75. recipe = {
  76. {"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"},
  77. {"default:steel_ingot", "group:stick", "default:steel_ingot"},
  78. {"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"},
  79. }
  80. })
  81. -- Brake rail
  82. boost_cart:register_rail(":carts:brakerail", {
  83. description = "Brake rail",
  84. tiles = {
  85. "carts_rail_straight_brk.png", "carts_rail_curved_brk.png",
  86. "carts_rail_t_junction_brk.png", "carts_rail_crossing_brk.png"
  87. },
  88. groups = boost_cart:get_rail_groups(),
  89. after_place_node = function(pos, placer, itemstack)
  90. if not mesecon then
  91. minetest.get_meta(pos):set_string("cart_acceleration", "-0.3")
  92. end
  93. end,
  94. mesecons = {
  95. effector = {
  96. action_on = function(pos, node)
  97. minetest.get_meta(pos):set_string("cart_acceleration", "-0.3")
  98. end,
  99. action_off = function(pos, node)
  100. minetest.get_meta(pos):set_string("cart_acceleration", "0")
  101. end,
  102. },
  103. },
  104. })
  105. minetest.register_craft({
  106. output = "carts:brakerail 6",
  107. recipe = {
  108. {"default:steel_ingot", "default:coal_lump", "default:steel_ingot"},
  109. {"default:steel_ingot", "group:stick", "default:steel_ingot"},
  110. {"default:steel_ingot", "default:coal_lump", "default:steel_ingot"},
  111. }
  112. })
  113. boost_cart:register_rail("boost_cart:startstoprail", {
  114. description = "Start-stop rail",
  115. tiles = {
  116. "carts_rail_straight_ss.png", "carts_rail_curved_ss.png",
  117. "carts_rail_t_junction_ss.png", "carts_rail_crossing_ss.png"
  118. },
  119. groups = boost_cart:get_rail_groups(),
  120. after_place_node = function(pos, placer, itemstack)
  121. if not mesecon then
  122. minetest.get_meta(pos):set_string("cart_acceleration", "halt")
  123. end
  124. end,
  125. mesecons = {
  126. effector = {
  127. action_on = function(pos, node)
  128. boost_cart:boost_rail(pos, 0.5)
  129. end,
  130. action_off = function(pos, node)
  131. minetest.get_meta(pos):set_string("cart_acceleration", "halt")
  132. end,
  133. },
  134. },
  135. })
  136. minetest.register_craft({
  137. type = "shapeless",
  138. output = "boost_cart:startstoprail 2",
  139. recipe = {"carts:powerrail", "carts:brakerail"},
  140. })