power.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. boost_cart:register_rail("boost_cart:powerrail", {
  2. description = "Powered rail",
  3. tiles = {
  4. "carts_rail_straight_brk.png", "carts_rail_curved_brk.png",
  5. "carts_rail_t_junction_brk.png", "carts_rail_crossing_brk.png"
  6. },
  7. groups = boost_cart:get_rail_groups({power_rail = 1}),
  8. mesecons = {
  9. effector = {
  10. action_on = function(pos, node)
  11. minetest.swap_node(pos, {name = "boost_cart:powerrail_on", param2 = node.param2})
  12. minetest.get_meta(pos):set_string("cart_acceleration", "1")
  13. end
  14. },
  15. },
  16. })
  17. minetest.register_craft({
  18. output = "boost_cart:powerrail 12",
  19. recipe = {
  20. {"default:steel_ingot", "group:stick", "default:steel_ingot"},
  21. {"default:steel_ingot", "default:mese_crystal_fragment", "default:steel_ingot"},
  22. {"default:steel_ingot", "group:stick", "default:steel_ingot"},
  23. }
  24. })
  25. -- Power rail on
  26. boost_cart:register_rail("boost_cart:powerrail_on", {
  27. description = "Power rail on",
  28. tiles = {
  29. "carts_rail_straight_pwr.png", "carts_rail_curved_pwr.png",
  30. "carts_rail_t_junction_pwr.png", "carts_rail_crossing_pwr.png"
  31. },
  32. groups = boost_cart:get_rail_groups({power_rail = 1, not_in_creative_inventory = 1}),
  33. drop = "boost_cart:powerrail",
  34. mesecons = {
  35. effector = {
  36. action_off = function(pos, node)
  37. minetest.swap_node(pos, {name = "boost_cart:powerrail", param2 = node.param2})
  38. minetest.get_meta(pos):set_string("cart_acceleration", "-1")
  39. end
  40. },
  41. },
  42. })