Carts for Minetest, but optimized! Also compatible with MTG carts https://content.minetest.net/packages/Krock/boost_cart/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
4.2KB

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