Added wheel, replaced tires_bunch item to wheels_bunch, optimized kamaz texture
42
api.lua
|
@ -155,14 +155,14 @@ local is_fallen
|
|||
-- Bounces a car only due to the falling.
|
||||
adv_vehicles.collide = function (vehicle)
|
||||
local vel = vehicle.object:get_velocity()
|
||||
local fixed_vel = vehicle.veh_vel
|
||||
local fixed_vel = vehicle.y_vel
|
||||
local seats_list = vehicle.seats_list
|
||||
local hp = vehicle.object:get_hp()
|
||||
if vel.y == 0 and fixed_vel ~= 0 then
|
||||
if not is_fallen then
|
||||
is_fallen = true
|
||||
local acc = vehicle.object:get_acceleration()
|
||||
vehicle.object:set_acceleration({x=acc.x, y=fixed_vel*-5, z=acc.z})
|
||||
vehicle.object:set_acceleration({x=acc.x, y=math.abs(fixed_vel)*10, z=acc.z})
|
||||
vehicle.object:set_hp(hp-math.abs(math.ceil(fixed_vel)), {type="fall"})
|
||||
for seated, data in pairs(seats_list) do
|
||||
if seated.busy_by then
|
||||
|
@ -186,8 +186,6 @@ adv_vehicles.vehicle_braking = function (vehicle, vector_l)
|
|||
local acc_x = -(vel.x*vector_l/vel_l)
|
||||
local acc_z = -(vel.z*vector_l/vel_l)
|
||||
local acc_y = obj:get_acceleration().y
|
||||
--minetest.debug(dump(obj:get_acceleration()))
|
||||
--minetest.debug(dump({x=acc_x, y=acc_y, z=acc_z}))
|
||||
obj:set_acceleration({x=acc_x, y=acc_y, z=acc_z})
|
||||
|
||||
local new_acc = obj:get_acceleration()
|
||||
|
@ -274,6 +272,8 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
|||
max_vel = veh_properties.max_vel or 120,
|
||||
collide_with_objects = true,
|
||||
collisionbox = veh_properties.cbox,
|
||||
selectionbox = veh_properties.sbox or veh_properties.cbox,
|
||||
pointable=true,
|
||||
mesh = veh_properties.model,
|
||||
textures = veh_properties.textures,
|
||||
visual_size = veh_properties.visual_size or {x=1, y=1, z=1},
|
||||
|
@ -290,9 +290,7 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
|||
self.seats_list[seated] = data
|
||||
self.seats_list[seated].pos.y = 0
|
||||
end
|
||||
self.veh_vel = 0
|
||||
self.smoke_emit = veh_properties.smoke_emit
|
||||
minetest.debug(dump(self.smoke_emit))
|
||||
self.y_vel = 0
|
||||
local acc = self.object:get_acceleration()
|
||||
local gravity_strength = veh_properties.mass * -9.8
|
||||
self.object:set_acceleration({x=acc.x, y=gravity_strength, z=acc.z})
|
||||
|
@ -307,7 +305,7 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
|||
local obj = entity.object
|
||||
local vel = obj:get_velocity()
|
||||
if vel.y ~= 0 then
|
||||
entity.veh_vel = vel.y
|
||||
entity.y_vel = vel.y
|
||||
end
|
||||
local acc = obj:get_acceleration()
|
||||
if acc.y > 0 then
|
||||
|
@ -365,40 +363,12 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
|||
if seated == "driver" then
|
||||
adv_vehicles.attach_player_to_veh(clicker, self, seated, "driver.b3d")
|
||||
self.is_veh_stopping=nil
|
||||
--minetest.debug(dump(self.smoke_emit))
|
||||
if self.smoke_emit then
|
||||
minetest.debug("TRUE")
|
||||
local sm_emit = self.smoke_emit
|
||||
self.smoke_spawner_id = minetest.add_particlespawner({
|
||||
amount = sm_emit.amount,
|
||||
time = 0,
|
||||
minpos = sm_emit.min_pos,
|
||||
maxpos = sm_emit.max_pos,
|
||||
minvel = sm_emit.min_vel,
|
||||
maxvel = sm_emit.max_vel,
|
||||
minacc = sm_emit.min_acc,
|
||||
maxacc = sm_emit.max_acc,
|
||||
minexptime = sm_emit.min_exp_time,
|
||||
maxexptime = sm_emit.max_exp_time,
|
||||
minsize = sm_emit.min_size,
|
||||
maxsize = sm_emit.max_size,
|
||||
collisiondetection = true,
|
||||
collision_removal = true,
|
||||
object_collision = true,
|
||||
attached = self.object,
|
||||
texture = sm_emit.texture or "default_item_smoke.png"
|
||||
})
|
||||
end
|
||||
else adv_vehicles.attach_player_to_veh(clicker, self, seated, nil, {x=81, y=81}) end
|
||||
break
|
||||
elseif data.busy_by == clicker:get_player_name() then
|
||||
if seated == "driver" then
|
||||
adv_vehicles.detach_player_from_veh(clicker, self, seated, "character.b3d")
|
||||
self.is_veh_stopping=true
|
||||
if self.smoke_spawner_id then
|
||||
minetest.delete_particlespawner(self.smoke_spawner_id)
|
||||
self.smoke_spawner_id=nil
|
||||
end
|
||||
else adv_vehicles.detach_player_from_veh(clicker, self, seated, nil, {x=1, y=80}) end
|
||||
break
|
||||
end
|
||||
|
|
44
init.lua
|
@ -19,9 +19,14 @@ minetest.register_craftitem("adv_vehicles:tire", {
|
|||
inventory_image = "tire.png"
|
||||
})
|
||||
|
||||
minetest.register_craftitem("adv_vehicles:tires_bunch", {
|
||||
description = "Bunch of tires",
|
||||
inventory_image = "tires_bunch.png"
|
||||
minetest.register_craftitem("adv_vehicles:wheel", {
|
||||
description = "Wheel",
|
||||
inventory_image = "wheel.png"
|
||||
})
|
||||
|
||||
minetest.register_craftitem("adv_vehicles:wheels_bunch", {
|
||||
description = "Bunch of wheels",
|
||||
inventory_image = "wheels_bunch.png"
|
||||
})
|
||||
|
||||
minetest.register_craftitem("adv_vehicles:steering_wheel", {
|
||||
|
@ -213,16 +218,25 @@ minetest.register_craft({
|
|||
output = "adv_vehicles:tire",
|
||||
recipe = {
|
||||
{plastic_itemstring, plastic_itemstring, "dye:dark_grey"},
|
||||
{"default:steel_ingot", plastic_itemstring, ""},
|
||||
{plastic_itemstring, "", ""},
|
||||
{"", "", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "adv_vehicles:tires_bunch",
|
||||
output = "adv_vehicles:wheel",
|
||||
recipe = {
|
||||
{"adv_vehicles:tire", "adv_vehicles:tire", "adv_vehicles:tire"},
|
||||
{"adv_vehicles:tire", "", ""},
|
||||
{"adv_vehicles:car_frame_material", "default:steel_ingot", ""},
|
||||
{"adv_vehicles:aluminium_dust", "adv_vehicles:tire", ""},
|
||||
{"", "", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "adv_vehicles:wheels_bunch",
|
||||
recipe = {
|
||||
{"adv_vehicles:wheel", "adv_vehicles:wheel", "adv_vehicles:wheel"},
|
||||
{"adv_vehicles:wheel", "", ""},
|
||||
{"", "", ""}
|
||||
}
|
||||
})
|
||||
|
@ -371,21 +385,9 @@ adv_vehicles.register_vehicle("bmw_118_two_seats", {
|
|||
acc_vector_length = 15.0,
|
||||
max_vel = 35.0,
|
||||
cbox = {-1.2, -0.5, -3.0, 1.2, 1.5, 3.0},
|
||||
sbox = {-1.2, -0.5, -3.0, 1.2, 1.5, 3.0},
|
||||
model = "bmw_118_two_seats_redone.b3d",
|
||||
textures = {"bmw_118_two_seats_new_tex.png"},
|
||||
smoke_emit = {
|
||||
amount = 6,
|
||||
min_pos = {x=-0.6, y=-0.2, z=-3.2},
|
||||
max_pos = {x=-0.5, y=-0.2, z=-3.2},
|
||||
min_vel = {x=0, y=0, z=-1.0},
|
||||
max_vel = {x=0, y=0, z=-1.3},
|
||||
min_acc = {x=0, y=0, z=0.25},
|
||||
max_acc = {x=0, y=0, z=0.35},
|
||||
min_exp_time = 0.8,
|
||||
max_exp_time = 2.0,
|
||||
min_size = 2,
|
||||
max_size = 4
|
||||
},
|
||||
seats = {["driver"]={busy_by=nil, pos={x=4.0, z=-3.5}, eye_offset={x=-3.0, z=5.0}},
|
||||
["passenger"]={busy_by=nil, pos={x=-8.0, z=-3.5}, eye_offset={x=3.0, z=5.0}}}
|
||||
}, {
|
||||
|
@ -418,6 +420,7 @@ adv_vehicles.register_vehicle("volvo", {
|
|||
acc_vector_length = 12.0,
|
||||
max_vel = 20.0,
|
||||
cbox = {-1.2, -0.5, -4.5, 1.2, 2.0, 4.5},
|
||||
sbox = {-1.2, -0.5, -4.5, 1.2, 2.0, 4.5},
|
||||
model = "volvo.b3d",
|
||||
textures = {"volvo.png"},
|
||||
seats = {["driver"]={busy_by=nil, pos={x=-4.5, z=-26.0}, eye_offset={x=4.0, z=31.0}},
|
||||
|
@ -446,6 +449,7 @@ adv_vehicles.register_vehicle("kamaz", {
|
|||
acc_vector_length = 10.5,
|
||||
max_vel = 16.0,
|
||||
cbox = {-1.5, -0.5, -3.5, 1.5, 2.5, 3.5},
|
||||
sbox = {-1.5, -0.5, -3.5, 1.5, 2.5, 3.5},
|
||||
model = "kamaz.b3d",
|
||||
textures = {"kamaz.png"},
|
||||
seats = {["driver"]={busy_by=nil, pos={x=0, z=-18.0}, eye_offset={x=0, z=28}},
|
||||
|
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 5.6 KiB |