1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-29 12:10:34 +01:00
server-nalc/mods/carts/rails.lua

161 lines
3.8 KiB
Lua
Raw Normal View History

minetest.register_node(":default:rail", {
2016-07-28 17:28:08 +02:00
description = "Rail",
drawtype = "raillike",
tiles = {
"default_rail.png", "default_rail_curved.png",
"default_rail_t_junction.png", "default_rail_crossing.png"
},
2016-07-28 17:28:08 +02:00
inventory_image = "default_rail.png",
wield_image = "default_rail.png",
paramtype = "light",
sunlight_propagates = true,
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
},
groups = carts:get_rail_groups(),
2016-07-28 17:28:08 +02:00
})
-- Copper rail
2016-07-28 17:28:08 +02:00
if minetest.get_modpath("moreores") then
-- Moreores' copper rail
minetest.register_alias("carts:rail_copper", "moreores:copper_rail")
else
carts:register_rail(":carts:rail_copper", {
description = "Copper rail",
tiles = {
"carts_rail_cp.png", "carts_rail_curved_cp.png",
"carts_rail_t_junction_cp.png", "carts_rail_crossing_cp.png"
},
groups = carts:get_rail_groups(),
})
minetest.register_craft({
output = "carts:rail_copper 16",
recipe = {
{"default:copper_ingot", "group:stick", "default:copper_ingot"},
{"default:copper_ingot", "group:stick", "default:copper_ingot"},
{"default:copper_ingot", "group:stick", "default:copper_ingot"},
}
})
end
-- Speed up
-- Rail Power
carts:register_rail(":carts:rail_power", {
description = "Powered rail",
tiles = {
"carts_rail_pwr.png", "carts_rail_curved_pwr.png",
"carts_rail_t_junction_pwr.png", "carts_rail_crossing_pwr.png"
2016-07-28 17:28:08 +02:00
},
groups = carts:get_rail_groups(),
2016-07-28 17:28:08 +02:00
after_place_node = function(pos, placer, itemstack)
if not mesecon then
minetest.get_meta(pos):set_string("cart_acceleration", "1")
end
2016-07-28 17:28:08 +02:00
end,
mesecons = {
2016-07-28 17:28:08 +02:00
effector = {
action_on = function(pos, node)
carts:boost_rail(pos, 1)
2016-07-28 17:28:08 +02:00
end,
action_off = function(pos, node)
2016-07-28 17:28:08 +02:00
minetest.get_meta(pos):set_string("cart_acceleration", "0")
end,
},
},
})
2016-07-28 17:28:08 +02:00
minetest.register_craft({
type = "shapeless",
output = "carts:rail_power",
recipe = {"group:rail", "default:mese_crystal_fragment"},
2016-07-28 17:28:08 +02:00
})
-- Rail Brake
carts:register_rail(":carts:rail_brake", {
description = "Brake rail",
tiles = {
"carts_rail_brk.png", "carts_rail_curved_brk.png",
"carts_rail_t_junction_brk.png", "carts_rail_crossing_brk.png"
2016-07-28 17:28:08 +02:00
},
groups = carts:get_rail_groups(),
2016-07-28 17:28:08 +02:00
after_place_node = function(pos, placer, itemstack)
if not mesecon then
minetest.get_meta(pos):set_string("cart_acceleration", "-1")
end
2016-07-28 17:28:08 +02:00
end,
mesecons = {
2016-07-28 17:28:08 +02:00
effector = {
action_on = function(pos, node)
minetest.get_meta(pos):set_string("cart_acceleration", "-1")
2016-07-28 17:28:08 +02:00
end,
action_off = function(pos, node)
2016-07-28 17:28:08 +02:00
minetest.get_meta(pos):set_string("cart_acceleration", "0")
end,
},
},
2016-07-28 17:28:08 +02:00
})
minetest.register_craft({
type = "shapeless",
output = "carts:rail_brake",
recipe = {"group:rail", "default:coal_lump"},
})
-- Start stop rail (temporary removed for mff)
--[[carts:register_rail("carts:startstoprail", {
description = "Start-stop rail",
tiles = {
"carts_rail_ss.png", "carts_rail_curved_ss.png",
"carts_rail_t_junction_ss.png", "carts_rail_crossing_ss.png"
2016-07-28 17:28:08 +02:00
},
groups = carts:get_rail_groups(),
2016-07-28 17:28:08 +02:00
after_place_node = function(pos, placer, itemstack)
if not mesecon then
minetest.get_meta(pos):set_string("cart_acceleration", "halt")
end
2016-07-28 17:28:08 +02:00
end,
mesecons = {
effector = {
action_on = function(pos, node)
carts:boost_rail(pos, 0.5)
end,
2016-07-28 17:28:08 +02:00
action_off = function(pos, node)
minetest.get_meta(pos):set_string("cart_acceleration", "halt")
end,
},
},
2016-07-28 17:28:08 +02:00
})
minetest.register_craft({
type = "shapeless",
output = "carts:startstoprail 2",
recipe = {"carts:powerrail", "carts:brakerail"},
})--]]
2016-07-28 17:28:08 +02:00
--Alias
2016-07-28 17:28:08 +02:00
minetest.register_alias("carts:powerrail", "carts:rail_power")
minetest.register_alias("carts:power_rail", "carts:rail_power")
minetest.register_alias("carts:brakerail", "carts:rail_brake")
minetest.register_alias("carts:brake_rail", "carts:rail_brake")