Compare commits
5 Commits
2720e07dfe
...
e40685f014
Author | SHA1 | Date |
---|---|---|
Andrey01 | e40685f014 | |
Andrey2470T | 07167ea8ed | |
Andrey2470T | 4fd10ab2c3 | |
Andrey01 | 70abda9091 | |
Andrey2470T | 98cb4c4193 |
33
README.md
|
@ -1,4 +1,4 @@
|
||||||
# Advanced Vehicles 1.0.0-Release Candidate #2
|
# Advanced Vehicles. Current version is 1.0.1-Release.
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
------------------------------
|
------------------------------
|
||||||
|
@ -41,15 +41,24 @@ Adds smart different cars (passenger cars, trucks, buses, service). This mod int
|
||||||
###adv_vehicles.detach_player_from_veh(player, vehicle, seated, model, animation)
|
###adv_vehicles.detach_player_from_veh(player, vehicle, seated, model, animation)
|
||||||
--Opposite to *adv_vehicles.attach_player_to_car*. Detaches a player from the car and the same arguments.
|
--Opposite to *adv_vehicles.attach_player_to_car*. Detaches a player from the car and the same arguments.
|
||||||
|
|
||||||
###adv_vehicles.pave_vector(vehicle, vect_length, old_yaw)
|
###adv_vehicles.pave_vector(vehicle, old_acc_vect_pos, old_yaw)
|
||||||
--Paves the vector from '0' point relatively to the car origin towards to *vect_length*.
|
--Paves the vector from '0' point relatively to the car origin towards to *old_acc_vect_pos*.
|
||||||
*old_yaw* is a integer value that saving in self.fixed_veh_rotate_angle.
|
*old_yaw* is a integer value that saving in self.fixed_veh_rotate_angle.
|
||||||
This method should be caused continuously per 0.1 second to recalculate the car direction.
|
This method should be caused continuously per 0.1 second to recalculate the car direction.
|
||||||
|
|
||||||
###adv_vehicles.rotate_collisionbox(vehicle, yaw)
|
###adv_vehicles.rotate_collisionbox(vehicle, yaw)
|
||||||
This method is WIP and doesnt work properly currently.
|
This method is WIP and doesnt work properly currently.
|
||||||
|
|
||||||
*This documentation is in working progress.*
|
###adv_vehicles.collide(vehicle)
|
||||||
|
Calculates elastic force of surface on that *vehicle* has fallen. It depends currently only on the vehicle velocity. It will also damage the vehicle and objects sitting inside. Damage rate also depends from the velocity.
|
||||||
|
|
||||||
|
###adv_vehicles.vehicle_braking(vehicle, vector_l)
|
||||||
|
*vector_l* is a just coefficient for braking calculating. The above value, the braking is faster. This method is permanently called in the globalstep.
|
||||||
|
|
||||||
|
###adv_vehicles.vehicle_handle(vehicle, controls, yaw)
|
||||||
|
*controls* is a table resulted from get_player_control().
|
||||||
|
|
||||||
|
Executes the vehicle driving (turns, forward/backward going)
|
||||||
|
|
||||||
## Crafting Recipes Guide
|
## Crafting Recipes Guide
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
@ -84,14 +93,14 @@ L/B plastic_sheet
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
***Tires Bunch***
|
***Wheels Bunch***
|
||||||
|
|
||||||
A group of *tires* items. An element is needed for crafting of all vehicles. Just made to save a room in the crafting grid for other items.
|
A group of *wheels* items. An element is needed for crafting of all vehicles. Just made to save a room in the crafting grid for other items.
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
adv_vehicles:tire === adv_vehicles:tire === adv_vehicles:tire
|
adv_vehicles:wheel === adv_vehicles:wheel === adv_vehicles:wheel
|
||||||
|
|
||||||
adv_vehicles:tire
|
adv_vehicles:wheel
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
@ -363,18 +372,18 @@ An element that intended for crafting of *tires bunch*
|
||||||
-------------------
|
-------------------
|
||||||
L/B plastic_sheet === L/B plastic_sheet === dye:dark_green
|
L/B plastic_sheet === L/B plastic_sheet === dye:dark_green
|
||||||
|
|
||||||
default:steel_ingot === L/B plastic_sheet
|
L/B plastic_sheet
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
***Wheel***
|
***Wheel***
|
||||||
|
|
||||||
An element of crafting of all vehicles. Available only **before** 1.0.0-RC2.
|
An element for crafting of *wheels_bunch*.
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
L/B plastic_sheet === L/B plastic_sheet === dye:dark_green
|
adv_vehicles:car_frame_material === default:steel_ingot
|
||||||
|
|
||||||
default:steel_ingot === L/B plastic_sheet
|
adv_vehicles:aluminium_dust === adv_vehicles:tire
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|
112
api.lua
|
@ -24,6 +24,11 @@ local function round_num(num)
|
||||||
return rounded_num
|
return rounded_num
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[adv_vehicles.get_obj_and_seat_pos = function(name)
|
||||||
|
minetest.debug(dump(vehs[name]))
|
||||||
|
return vehs[name]
|
||||||
|
end]]
|
||||||
|
|
||||||
local is_car_driven = nil
|
local is_car_driven = nil
|
||||||
-- The method calculates new position for any car seat (for example, after a car turning)
|
-- The method calculates new position for any car seat (for example, after a car turning)
|
||||||
adv_vehicles.rotate_point_around_other_point = function (circle_centre_pos, rotating_point_pos, fixed_point_yaw, current_point_yaw)
|
adv_vehicles.rotate_point_around_other_point = function (circle_centre_pos, rotating_point_pos, fixed_point_yaw, current_point_yaw)
|
||||||
|
@ -34,23 +39,27 @@ adv_vehicles.rotate_point_around_other_point = function (circle_centre_pos, rota
|
||||||
return new_pos
|
return new_pos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
vehs = {}
|
||||||
-- The method attaches a player to the car
|
-- The method attaches a player to the car
|
||||||
adv_vehicles.attach_player_to_veh = function(player, vehicle, seated, model, animation)
|
adv_vehicles.attach_player_to_veh = function(player, vehicle, seated, model, animation)
|
||||||
if vehicle.seats_list[seated].busy_by then
|
if vehicle.seats_list[seated].busy_by then
|
||||||
minetest.chat_send_player(player:get_player_name(), "This seat is busy by" .. vehicle.seats_list[seated].busy_by .. "!")
|
minetest.chat_send_player(player:get_player_name(), "This seat is busy by" .. vehicle.seats_list[seated].busy_by .. "!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local name = player:get_player_name()
|
||||||
|
vehs[name] = {}
|
||||||
|
--vehs[name].obj = vehicle
|
||||||
vehicle.seats_list[seated].busy_by = player:get_player_name()
|
vehicle.seats_list[seated].busy_by = player:get_player_name()
|
||||||
local veh_rot = vehicle.object:get_rotation()
|
local veh_rot = vehicle.object:get_rotation()
|
||||||
local new_seat_pos = adv_vehicles.rotate_point_around_other_point({x=0, y=0, z=0}, vehicle.seats_list[seated].pos, vehicle.fixed_veh_rotate_angle, veh_rot.y)
|
local new_seat_pos = adv_vehicles.rotate_point_around_other_point({x=0, y=0, z=0}, vehicle.seats_list[seated].pos, vehicle.fixed_veh_rotate_angle, veh_rot.y)
|
||||||
|
vehs[name].r_seat_pos = new_seat_pos
|
||||||
new_seat_pos.y = 9
|
new_seat_pos.y = 9
|
||||||
vehicle.seats_list[seated].pos = new_seat_pos
|
vehicle.seats_list[seated].pos = new_seat_pos
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
meta:set_string("is_sit", minetest.serialize({veh_name, seated}))
|
meta:set_string("is_sit", minetest.serialize({veh_name, seated}))
|
||||||
local new_player_rot = {x=math.deg(veh_rot.x), y=veh_rot.y+180, z=math.deg(veh_rot.z)}
|
local new_player_rot = {x=math.deg(veh_rot.x), y=veh_rot.y+180, z=math.deg(veh_rot.z)}
|
||||||
local p=vehicle.object:get_pos()
|
local p=vehicle.object:get_pos()
|
||||||
--player:set_pos({x=p.x+vehicle.seats_list[seated].pos.x, y=p.y, z=p.z+vehicle.seats_list[seated].pos.z})
|
--player:set_pos({x=p.x+new_seat_pos.x, y=p.y, z=p.z+new_seat_pos.z})
|
||||||
local eye_offset_fi, eye_offset_th = player:get_eye_offset()
|
local eye_offset_fi, eye_offset_th = player:get_eye_offset()
|
||||||
if vehicle.seats_list[seated].eye_offset then
|
if vehicle.seats_list[seated].eye_offset then
|
||||||
local eye_off = vehicle.seats_list[seated].eye_offset
|
local eye_off = vehicle.seats_list[seated].eye_offset
|
||||||
|
@ -80,6 +89,8 @@ adv_vehicles.detach_player_from_veh = function (player, vehicle, seated, model,
|
||||||
if not vehicle.seats_list[seated].busy_by then
|
if not vehicle.seats_list[seated].busy_by then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local name = player:get_player_name()
|
||||||
|
vehs[name] = nil
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
meta:set_string("is_sit", "")
|
meta:set_string("is_sit", "")
|
||||||
vehicle.seats_list[seated].busy_by = nil
|
vehicle.seats_list[seated].busy_by = nil
|
||||||
|
@ -155,14 +166,14 @@ local is_fallen
|
||||||
-- Bounces a car only due to the falling.
|
-- Bounces a car only due to the falling.
|
||||||
adv_vehicles.collide = function (vehicle)
|
adv_vehicles.collide = function (vehicle)
|
||||||
local vel = vehicle.object:get_velocity()
|
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 seats_list = vehicle.seats_list
|
||||||
local hp = vehicle.object:get_hp()
|
local hp = vehicle.object:get_hp()
|
||||||
if vel.y == 0 and fixed_vel ~= 0 then
|
if vel.y == 0 and fixed_vel ~= 0 then
|
||||||
if not is_fallen then
|
if not is_fallen then
|
||||||
is_fallen = true
|
is_fallen = true
|
||||||
local acc = vehicle.object:get_acceleration()
|
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"})
|
vehicle.object:set_hp(hp-math.abs(math.ceil(fixed_vel)), {type="fall"})
|
||||||
for seated, data in pairs(seats_list) do
|
for seated, data in pairs(seats_list) do
|
||||||
if seated.busy_by then
|
if seated.busy_by then
|
||||||
|
@ -195,32 +206,70 @@ adv_vehicles.vehicle_braking = function (vehicle, vector_l)
|
||||||
obj:set_acceleration({x=0, y=new_acc.y, z=0})
|
obj:set_acceleration({x=0, y=new_acc.y, z=0})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local R_ANGLE_TURN_ACC = 1 -- Acceleration value of turn (to right)
|
||||||
|
local L_ANGLE_TURN_ACC = 1 -- Acceleration value of turn (to left)
|
||||||
-- Implements vehicle controls (turning, moving forward/backwards).
|
-- Implements vehicle controls (turning, moving forward/backwards).
|
||||||
adv_vehicles.vehicle_handle = function (vehicle, controls, yaw)
|
adv_vehicles.vehicle_handle = function (vehicle, controls, yaw)
|
||||||
local vel_l = vector.length(vehicle.object:get_velocity())
|
local vel_l = vector.length(vehicle.object:get_velocity())
|
||||||
local new_yaw=math.deg(yaw)
|
local new_yaw=math.deg(yaw)
|
||||||
|
local acc = vehicle.object:get_acceleration()
|
||||||
if controls.right and vel_l ~= 0 then
|
if controls.right and vel_l ~= 0 then
|
||||||
vehicle.object:set_yaw(yaw-math.rad(1))
|
vehicle.object:set_yaw(yaw-math.rad(R_ANGLE_TURN_ACC))
|
||||||
|
if R_ANGLE_TURN_ACC < 25 then
|
||||||
|
R_ANGLE_TURN_ACC = R_ANGLE_TURN_ACC+vel_l-acc.y
|
||||||
|
end
|
||||||
new_yaw = math.deg(vehicle.object:get_yaw())
|
new_yaw = math.deg(vehicle.object:get_yaw())
|
||||||
local fixed_cbox_yaw = vehicle.collisionbox_yaw.val
|
local fixed_cbox_yaw = vehicle.collisionbox_yaw.val
|
||||||
if new_yaw-fixed_cbox_yaw <= -90 then
|
if new_yaw-fixed_cbox_yaw <= -90 then
|
||||||
--minetest.debug("1")
|
--minetest.debug("1")
|
||||||
adv_vehicles.rotate_collisionbox(vehicle, -90)
|
adv_vehicles.rotate_collisionbox(vehicle, -90)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if R_ANGLE_TURN_ACC > 1 then -- If the vehicle was turned with an acceleration in last step, then decelerates the vehicle turn.
|
||||||
|
R_ANGLE_TURN_ACC = R_ANGLE_TURN_ACC - 1
|
||||||
|
vehicle.object:set_yaw(yaw+math.rad(R_ANGLE_TURN_ACC))
|
||||||
|
else
|
||||||
|
R_ANGLE_TURN_ACC = 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if controls.left and vel_l ~= 0 then
|
if controls.left and vel_l ~= 0 then
|
||||||
vehicle.object:set_yaw(yaw+math.rad(1))
|
vehicle.object:set_yaw(yaw+math.rad(L_ANGLE_TURN_ACC))
|
||||||
|
if L_ANGLE_TURN_ACC < 25 then
|
||||||
|
L_ANGLE_TURN_ACC = L_ANGLE_TURN_ACC+vel_l-acc.y
|
||||||
|
end
|
||||||
new_yaw = math.deg(vehicle.object:get_yaw())
|
new_yaw = math.deg(vehicle.object:get_yaw())
|
||||||
local fixed_cbox_yaw = vehicle.collisionbox_yaw.val
|
local fixed_cbox_yaw = vehicle.collisionbox_yaw.val
|
||||||
if new_yaw+fixed_cbox_yaw >= 90 then
|
if new_yaw+fixed_cbox_yaw >= 90 then
|
||||||
--minetest.debug("2")
|
--minetest.debug("2")
|
||||||
adv_vehicles.rotate_collisionbox(vehicle, 90)
|
adv_vehicles.rotate_collisionbox(vehicle, 90)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if L_ANGLE_TURN_ACC > 1 then
|
||||||
|
L_ANGLE_TURN_ACC = L_ANGLE_TURN_ACC - 1
|
||||||
|
vehicle.object:set_yaw(yaw-math.rad(L_ANGLE_TURN_ACC))
|
||||||
|
else
|
||||||
|
L_ANGLE_TURN_ACC = 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local acc = vehicle.object:get_acceleration()
|
local up_and_down_vals = {controls.up, controls.down}
|
||||||
if controls.up then
|
local t = {1, -1}
|
||||||
|
local s
|
||||||
|
for i, v in pairs(up_and_down_vals) do
|
||||||
|
if v then
|
||||||
|
s = t[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (controls.up and s) or (controls.down and s) then
|
||||||
|
is_car_driven=true
|
||||||
|
vehicle.object:set_acceleration({x=vehicle.acc_vector_pos.x*s, y=acc.y, z=vehicle.acc_vector_pos.z*s})
|
||||||
|
else
|
||||||
|
is_car_driven=nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[if controls.up then
|
||||||
is_car_driven=true
|
is_car_driven=true
|
||||||
vehicle.object:set_acceleration({x=vehicle.acc_vector_pos.x, y=acc.y, z=vehicle.acc_vector_pos.z})
|
vehicle.object:set_acceleration({x=vehicle.acc_vector_pos.x, y=acc.y, z=vehicle.acc_vector_pos.z})
|
||||||
else
|
else
|
||||||
|
@ -232,7 +281,7 @@ adv_vehicles.vehicle_handle = function (vehicle, controls, yaw)
|
||||||
vehicle.object:set_acceleration({x=vehicle.acc_vector_pos.x*-1, y=acc.y, z=vehicle.acc_vector_pos.z*-1})
|
vehicle.object:set_acceleration({x=vehicle.acc_vector_pos.x*-1, y=acc.y, z=vehicle.acc_vector_pos.z*-1})
|
||||||
else
|
else
|
||||||
is_car_driven=nil
|
is_car_driven=nil
|
||||||
end
|
end ]]
|
||||||
return math.rad(new_yaw)
|
return math.rad(new_yaw)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -247,7 +296,6 @@ end
|
||||||
local nearby_nodes = minetest.find_node_near(pos, z_face, global_nodenames_list)]]
|
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.
|
-- 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)
|
adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
||||||
minetest.register_entity("adv_vehicles:"..vehname, {
|
minetest.register_entity("adv_vehicles:"..vehname, {
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
@ -257,6 +305,8 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
||||||
max_vel = veh_properties.max_vel or 120,
|
max_vel = veh_properties.max_vel or 120,
|
||||||
collide_with_objects = true,
|
collide_with_objects = true,
|
||||||
collisionbox = veh_properties.cbox,
|
collisionbox = veh_properties.cbox,
|
||||||
|
selectionbox = veh_properties.sbox or veh_properties.cbox,
|
||||||
|
pointable=true,
|
||||||
mesh = veh_properties.model,
|
mesh = veh_properties.model,
|
||||||
textures = veh_properties.textures,
|
textures = veh_properties.textures,
|
||||||
visual_size = veh_properties.visual_size or {x=1, y=1, z=1},
|
visual_size = veh_properties.visual_size or {x=1, y=1, z=1},
|
||||||
|
@ -273,8 +323,7 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
||||||
self.seats_list[seated] = data
|
self.seats_list[seated] = data
|
||||||
self.seats_list[seated].pos.y = 0
|
self.seats_list[seated].pos.y = 0
|
||||||
end
|
end
|
||||||
self.veh_vel = 0
|
self.y_vel = 0
|
||||||
|
|
||||||
local acc = self.object:get_acceleration()
|
local acc = self.object:get_acceleration()
|
||||||
local gravity_strength = veh_properties.mass * -9.8
|
local gravity_strength = veh_properties.mass * -9.8
|
||||||
self.object:set_acceleration({x=acc.x, y=gravity_strength, z=acc.z})
|
self.object:set_acceleration({x=acc.x, y=gravity_strength, z=acc.z})
|
||||||
|
@ -289,7 +338,7 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
||||||
local obj = entity.object
|
local obj = entity.object
|
||||||
local vel = obj:get_velocity()
|
local vel = obj:get_velocity()
|
||||||
if vel.y ~= 0 then
|
if vel.y ~= 0 then
|
||||||
entity.veh_vel = vel.y
|
entity.y_vel = vel.y
|
||||||
end
|
end
|
||||||
local acc = obj:get_acceleration()
|
local acc = obj:get_acceleration()
|
||||||
if acc.y > 0 then
|
if acc.y > 0 then
|
||||||
|
@ -299,16 +348,10 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
||||||
|
|
||||||
-- Further it will get new position for the acceleration vector dependently on fixed rotation angle and fix new rotation angles.
|
-- Further it will get new position for the acceleration vector dependently on fixed rotation angle and fix new rotation angles.
|
||||||
entity.acc_vector_pos, entity.fixed_veh_rotate_angle = adv_vehicles.pave_vector(entity, entity.acc_vector_pos, entity.fixed_veh_rotate_angle)
|
entity.acc_vector_pos, entity.fixed_veh_rotate_angle = adv_vehicles.pave_vector(entity, entity.acc_vector_pos, entity.fixed_veh_rotate_angle)
|
||||||
for seat, d in pairs(entity.seats_list) do
|
if entity.seats_list["driver"].busy_by then
|
||||||
if d.busy_by then
|
local player = minetest.get_player_by_name(entity.seats_list["driver"].busy_by)
|
||||||
local player = minetest.get_player_by_name(d.busy_by)
|
yaw = entity.on_handle(entity, player:get_player_control(), yaw)
|
||||||
local is_sit = minetest.deserialize(player:get_meta():get_string("is_sit"))
|
|
||||||
if is_sit[2] == "driver" then
|
|
||||||
yaw = entity.on_handle(entity, player:get_player_control(), yaw)
|
|
||||||
end
|
|
||||||
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.
|
-- If a length of the velocity vector exceeds a 'max_vel' value, sets to zero the acceleration vector.
|
||||||
local vel_length = vector.length(vel)
|
local vel_length = vector.length(vel)
|
||||||
|
@ -375,7 +418,6 @@ adv_vehicles.register_vehicle = function (vehname, veh_properties, veh_item)
|
||||||
local object = minetest.add_entity(pointed_thing.above, "adv_vehicles:"..vehname)
|
local object = minetest.add_entity(pointed_thing.above, "adv_vehicles:"..vehname)
|
||||||
local yaw = math.deg(placer:get_look_horizontal())
|
local yaw = math.deg(placer:get_look_horizontal())
|
||||||
object:set_yaw(math.rad(yaw+180))
|
object:set_yaw(math.rad(yaw+180))
|
||||||
--is_origin_yaw_set=true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -400,7 +442,27 @@ end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)]]
|
end)]]
|
||||||
|
--[[minetest.register_on_leaveplayer(function(player)
|
||||||
|
if not vehs then
|
||||||
|
vehs = {}
|
||||||
|
end
|
||||||
|
local meta = minetest.deserialize(player:get_meta():get_string("is_sit"))
|
||||||
|
if meta then
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local attached_to =
|
||||||
|
vehs[name] = ]]
|
||||||
|
--[[minetest.register_on_joinplayer(function(player)
|
||||||
|
--minetest.debug(dump(vehs))
|
||||||
|
local meta = minetest.deserialize(player:get_meta():get_string("is_sit"))
|
||||||
|
if meta then
|
||||||
|
local yaw = player:get_yaw()
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local data = adv_vehicles.get_obj_and_seat_pos(name)
|
||||||
|
--local new_obj = data.obj:get_luaentity()
|
||||||
|
--player:set_attach(new_obj, "", data.r_seat_pos, yaw)
|
||||||
|
end
|
||||||
|
end)]]
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function (player)
|
minetest.register_on_dieplayer(function (player)
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
if meta:get_string("is_sit") ~= (nil or "") then
|
if meta:get_string("is_sit") ~= (nil or "") then
|
||||||
|
|
45
init.lua
|
@ -19,9 +19,14 @@ minetest.register_craftitem("adv_vehicles:tire", {
|
||||||
inventory_image = "tire.png"
|
inventory_image = "tire.png"
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("adv_vehicles:tires_bunch", {
|
minetest.register_craftitem("adv_vehicles:wheel", {
|
||||||
description = "Bunch of tires",
|
description = "Wheel",
|
||||||
inventory_image = "tires_bunch.png"
|
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", {
|
minetest.register_craftitem("adv_vehicles:steering_wheel", {
|
||||||
|
@ -213,16 +218,25 @@ minetest.register_craft({
|
||||||
output = "adv_vehicles:tire",
|
output = "adv_vehicles:tire",
|
||||||
recipe = {
|
recipe = {
|
||||||
{plastic_itemstring, plastic_itemstring, "dye:dark_grey"},
|
{plastic_itemstring, plastic_itemstring, "dye:dark_grey"},
|
||||||
{"default:steel_ingot", plastic_itemstring, ""},
|
{plastic_itemstring, "", ""},
|
||||||
{"", "", ""}
|
{"", "", ""}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "adv_vehicles:tires_bunch",
|
output = "adv_vehicles:wheel",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"adv_vehicles:tire", "adv_vehicles:tire", "adv_vehicles:tire"},
|
{"adv_vehicles:car_frame_material", "default:steel_ingot", ""},
|
||||||
{"adv_vehicles:tire", "", ""},
|
{"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", "", ""},
|
||||||
{"", "", ""}
|
{"", "", ""}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -368,9 +382,10 @@ minetest.register_craft({
|
||||||
adv_vehicles.register_vehicle("bmw_118_two_seats", {
|
adv_vehicles.register_vehicle("bmw_118_two_seats", {
|
||||||
hp_max = 60,
|
hp_max = 60,
|
||||||
mass = 1.3,
|
mass = 1.3,
|
||||||
acc_vector_length = 10.0,
|
acc_vector_length = 15.0,
|
||||||
max_vel = 10,
|
max_vel = 35.0,
|
||||||
cbox = {-1.2, -0.5, -3.0, 1.2, 1.5, 3.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",
|
model = "bmw_118_two_seats_redone.b3d",
|
||||||
textures = {"bmw_118_two_seats_new_tex.png"},
|
textures = {"bmw_118_two_seats_new_tex.png"},
|
||||||
seats = {["driver"]={busy_by=nil, pos={x=4.0, z=-3.5}, eye_offset={x=-3.0, z=5.0}},
|
seats = {["driver"]={busy_by=nil, pos={x=4.0, z=-3.5}, eye_offset={x=-3.0, z=5.0}},
|
||||||
|
@ -402,9 +417,10 @@ end
|
||||||
adv_vehicles.register_vehicle("volvo", {
|
adv_vehicles.register_vehicle("volvo", {
|
||||||
hp_max = 130,
|
hp_max = 130,
|
||||||
mass = 25,
|
mass = 25,
|
||||||
acc_vector_length = 6.5,
|
acc_vector_length = 12.0,
|
||||||
max_vel = 3,
|
max_vel = 20.0,
|
||||||
cbox = {-1.2, -0.5, -4.5, 1.2, 2.0, 4.5},
|
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",
|
model = "volvo.b3d",
|
||||||
textures = {"volvo.png"},
|
textures = {"volvo.png"},
|
||||||
seats = {["driver"]={busy_by=nil, pos={x=-4.5, z=-26.0}, eye_offset={x=4.0, z=31.0}},
|
seats = {["driver"]={busy_by=nil, pos={x=-4.5, z=-26.0}, eye_offset={x=4.0, z=31.0}},
|
||||||
|
@ -430,12 +446,13 @@ adv_vehicles.register_vehicle("volvo", {
|
||||||
adv_vehicles.register_vehicle("kamaz", {
|
adv_vehicles.register_vehicle("kamaz", {
|
||||||
hp_max = 160,
|
hp_max = 160,
|
||||||
mass = 40,
|
mass = 40,
|
||||||
acc_vector_length = 6.0,
|
acc_vector_length = 10.5,
|
||||||
max_vel = 1.5,
|
max_vel = 16.0,
|
||||||
cbox = {-1.5, -0.5, -3.5, 1.5, 2.5, 3.5},
|
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",
|
model = "kamaz.b3d",
|
||||||
textures = {"kamaz.png"},
|
textures = {"kamaz.png"},
|
||||||
seats = {["driver"]={busy_by=nil, pos={x=0, z=-18.0}},
|
seats = {["driver"]={busy_by=nil, pos={x=0, z=-18.0}, eye_offset={x=0, z=28}},
|
||||||
},
|
},
|
||||||
player_eye_offset = {x=0, y=0, z=-18.0}
|
player_eye_offset = {x=0, y=0, z=-18.0}
|
||||||
}, {
|
}, {
|
||||||
|
|
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 |