--[[local t = tonumber(minetest.get_meta(pos):get_string("cart_touring_velocity")) if not t then t=0 end t = 0 if t>0 then local vx=math.abs(self.velocity.x) local vy=math.abs(self.velocity.y) local vz=math.abs(self.velocity.z) -- make v the largest of the 3 velocities local v=vx if vy>v then v=vy end if vz>v then v=vz end -- local diff=0 local acelordecl=0 if v>t then diff=v-t acelordecl=-1 elseif vt --minetest.log("action", " on_step t1 v="..v.." t="..t.." diff="..diff.." a="..a.." acelordecl="..acelordecl) --adjust for grav if self.velocity.y<0 then --going downhill so grav will acel by extra 0.13 --if we are decel then add an extra 0.13 to how much we need to decel --if we are accel then subtract an extra 0.13 from how much we need to acel diff=diff-(0.13*acelordecl) elseif self.velocity.y>0 then --going uphill grav will decl by extra 0.10 --if we are decel then subtract 0.1 from how much we need to decel --if we are acel then add 0.1 to how much we need to acel diff=diff+(0.1*acelordecl) end -- self.velocity.y<0 --so now diff is the difference between cart velocity (after this turns grav) --and our target touring velocity --minetest.log("action", "*!* on_step t2 grav v="..v.." diff="..diff.." a="..a) if diffa*4 then a=a*2 --if big difference, play catchup fast! elseif diff>a*3 then a=a*1.5 --if big difference, play catchup fast! end --diff0--]] --[[minetest.register_node("carts:rail_tour", { description = "Touring Rail", drawtype = "raillike", tiles = {"carts_rail_tour.png", "carts_rail_curved_tour.png", "carts_rail_t_junction_tour.png", "carts_rail_crossing_tour.png"}, inventory_image = "carts_rail_tour.png", wield_image = "carts_rail_tour.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 = {bendy = 2, snappy = 1, dig_immediate = 2, 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", "0.5") minetest.get_meta(pos):set_string("cart_touring_velocity", cart.TARGET_TOUR_V) end end, mesecons = { effector = { action_on = function(pos, node) minetest.get_meta(pos):set_string("cart_acceleration", "0.5") end, action_off = function(pos, node) minetest.get_meta(pos):set_string("cart_acceleration", "0") end, }, }, }) --]] --[[minetest.register_craft({ type = "shapeless", output = "carts:rail_tour", recipe = {"group:rail", "default:clay_lump"}, })--]] --minetest.register_alias("carts:tourrail", "carts:rail_tour") -- temporary --[[minetest.register_abm({ nodes = {"group:rail"}, func = function(pos) local name = minetest.get_node(pos).name minetest.remove_node(pos) minetest.place_node(pos,{name = name}) end })--]]