From 656945076a1df816a40a3bc48188ce66a7c4516a Mon Sep 17 00:00:00 2001 From: Andrey2470T Date: Sat, 27 Jul 2019 22:41:28 +0300 Subject: [PATCH] vehicle_braking(): Compares '0.03' num with a vector length instead velocity coords values --- api.lua | 10 ++++------ init.lua | 18 +++++++++--------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/api.lua b/api.lua index 955c0b4..7b79e34 100644 --- a/api.lua +++ b/api.lua @@ -190,8 +190,9 @@ adv_vehicles.vehicle_braking = function (vehicle, vector_l) local new_acc = obj:get_acceleration() local new_vel = obj:get_velocity() - if (math.abs(new_vel.x) and math.abs(new_vel.z)) < 0.03 and not is_car_driven then - minetest.debug("TRUE") + local new_vel_l = vector.length(new_vel) + minetest.debug(vector.length(new_vel)) + if new_vel_l < 0.03 and not is_car_driven then obj:set_velocity({x=0, y=new_vel.y, z=0}) obj:set_acceleration({x=0, y=new_acc.y, z=0}) end @@ -248,7 +249,6 @@ end local nearby_nodes = minetest.find_node_near(pos, z_face, global_nodenames_list)]] -- Registers a vehicle to the world and creates a spawner item for it with a crafting recipe. -local is_origin_yaw_set adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item) minetest.register_entity("adv_vehicles:"..vehname, { visual = "mesh", @@ -309,14 +309,13 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item) end end end - --entity.fixed_veh_rotate_angle = obj:get_yaw() -- If a length of the velocity vector exceeds a 'max_vel' value, sets to zero the acceleration vector. local vel_length = vector.length(vel) if vel_length >= veh_properties.max_vel then obj:set_acceleration({x=0, y=gravity_strength, z=0}) end - if not is_car_driven and (vel.x and vel.z) ~= 0 then + if not is_car_driven and vel_length ~= 0 then adv_vehicles.vehicle_braking(entity, 8) end end @@ -376,7 +375,6 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item) local object = minetest.add_entity(pointed_thing.above, "adv_vehicles:"..vehname) local yaw = math.deg(placer:get_look_horizontal()) object:set_yaw(math.rad(yaw+180)) - --is_origin_yaw_set=true end end }) diff --git a/init.lua b/init.lua index 3760831..2462a85 100644 --- a/init.lua +++ b/init.lua @@ -9,9 +9,9 @@ local function random_dropped_items_amount(player, itemstack, max_items_amount) inv:add_item("main", stack) end -minetest.register_craftitem("adv_vehicles:car_frame", { - description = "Car Frame (raw)", - inventory_image = "car_frame.png" +minetest.register_craftitem("adv_vehicles:car_frame_material", { + description = "Car Frame Material", + inventory_image = "car_frame_material.png" }) minetest.register_craftitem("adv_vehicles:wheel", { @@ -117,19 +117,19 @@ else end minetest.register_craft({ - output = "adv_vehicles:car_frame", + output = "adv_vehicles:car_frame_material", recipe = { - {plastic_itemstring, plastic_itemstring, plastic_itemstring}, - {plastic_itemstring, plastic_itemstring, plastic_itemstring}, - {plastic_itemstring, "", ""} + {"default:steel_ingot", "adv_vehicles:aluminium_dust", "adv_vehicles:aluminium_dust"}, + {"default:steel_ingot", plastic_itemstring, plastic_itemstring}, + {plastic_itemstring, "xpanes:pane_flat", ""} } }) minetest.register_craft({ output = "adv_vehicles:wheel", recipe = { - {plastic_itemstring, plastic_itemstring, "dye:dark_grey"}, - {"default:steel_ingot", plastic_itemstring, ""}, + {"technic:rubber", "technic:rubber", plastic_itemstring}, + {"default:steel_ingot", "technic:rubber", ""}, {"", "", ""} } })