diff --git a/init.lua b/init.lua index 4531042..3619bd8 100644 --- a/init.lua +++ b/init.lua @@ -249,8 +249,16 @@ function boost_cart.cart:on_step(dtime) -- Slow down or speed up.. local acc = dir.y * -1.8 - local speed_mod = tonumber(minetest.get_meta(pos):get_string("cart_acceleration")) - if speed_mod and speed_mod ~= 0 then + local speed_mod_string = minetest.get_meta(pos):get_string("cart_acceleration") + local speed_mod = tonumber(speed_mod_string) + if speed_mod_string == "halt" then + vel = {x=0, y=0, z=0} + acc = {x=0, y=0, z=0} + dir = {x=0, y=0, z=0} + pos = vector.round(pos) + update.pos = true + update.vel = true + elseif speed_mod and speed_mod ~= 0 then if speed_mod > 0 then for _,v in ipairs({"x","y","z"}) do if math.abs(vel[v]) >= max_vel then @@ -363,4 +371,4 @@ minetest.register_craft({ {"default:steel_ingot", "", "default:steel_ingot"}, {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, }, -}) \ No newline at end of file +}) diff --git a/rails.lua b/rails.lua index 02c5f48..abf5aa3 100644 --- a/rails.lua +++ b/rails.lua @@ -101,4 +101,34 @@ minetest.register_craft({ {"default:steel_ingot", "group:stick", "default:steel_ingot"}, {"default:steel_ingot", "default:coal_lump", "default:steel_ingot"}, } -}) \ No newline at end of file +}) + +boost_cart:register_rail(":boost_cart: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"}, + groups = {dig_immediate = 2, attached_node = 1, rail = 1, connect_to_raillike = 1}, + + after_place_node = function(pos, placer, itemstack) + if not mesecon then + minetest.get_meta(pos):set_string("cart_acceleration", "halt") + end + end, + + mesecons = { + effector = { + action_on = function(pos, node) + boost_cart:boost_rail(pos, 0.5) + end, + + action_off = function(pos, node) + minetest.get_meta(pos):set_string("cart_acceleration", "halt") + end, + }, + }, +}) + +minetest.register_craft({ + type = "shapeless", + output = "boost_cart:startstoprail 2", + recipe = {"carts:powerrail", "carts:brakerail"}, +}) diff --git a/textures/carts_rail_crossing_ss.png b/textures/carts_rail_crossing_ss.png new file mode 100644 index 0000000..69ee070 Binary files /dev/null and b/textures/carts_rail_crossing_ss.png differ diff --git a/textures/carts_rail_curved_ss.png b/textures/carts_rail_curved_ss.png new file mode 100644 index 0000000..504e31f Binary files /dev/null and b/textures/carts_rail_curved_ss.png differ diff --git a/textures/carts_rail_ss.png b/textures/carts_rail_ss.png new file mode 100644 index 0000000..489e7fe Binary files /dev/null and b/textures/carts_rail_ss.png differ diff --git a/textures/carts_rail_t_junction_ss.png b/textures/carts_rail_t_junction_ss.png new file mode 100644 index 0000000..c1a2cb1 Binary files /dev/null and b/textures/carts_rail_t_junction_ss.png differ