mirror of
https://github.com/APercy/automobiles_pck
synced 2025-06-17 06:18:01 +02:00
trans am now have a rudimentary automatic transmission emulation
This commit is contained in:
parent
92f32b2cc0
commit
8b61e80ad7
@ -446,6 +446,13 @@ function automobiles_lib.paint_with_mask(self, colstr, mask_colstr, target_textu
|
||||
end
|
||||
end
|
||||
|
||||
-- very basic transmission emulation for the car
|
||||
function automobiles_lib.get_transmission_state(curr_speed, max_speed)
|
||||
local retVal = 1
|
||||
if curr_speed >= (max_speed/4) then retVal = 2 end
|
||||
return retVal
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "physics_lib.lua")
|
||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "custom_physics.lua")
|
||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua")
|
||||
|
@ -304,7 +304,8 @@ minetest.register_entity("automobiles_trans_am:trans_am", {
|
||||
_change_color = automobiles_lib.paint,
|
||||
_intensity = 4,
|
||||
_car_gravity = -automobiles_lib.gravity,
|
||||
_is_flying = 0,
|
||||
--acc control
|
||||
_transmission_state = 1,
|
||||
|
||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||
return minetest.serialize({
|
||||
@ -582,7 +583,20 @@ minetest.register_entity("automobiles_trans_am:trans_am", {
|
||||
local mid_speed = (steering_speed/2)
|
||||
steering_speed = mid_speed + mid_speed / math.abs(longit_speed*0.25)
|
||||
end
|
||||
accel, stop = automobiles_lib.control(self, dtime, hull_direction, longit_speed, longit_drag, later_drag, accel, trans_am.max_acc_factor, trans_am.max_speed, steering_angle_max, steering_speed)
|
||||
|
||||
--adjust engine parameter (transmission emulation)
|
||||
local acc_factor = trans_am.max_acc_factor
|
||||
local transmission_state = automobiles_lib.get_transmission_state(longit_speed, trans_am.max_speed)
|
||||
|
||||
local target_acc_factor = acc_factor
|
||||
if transmission_state == 1 then
|
||||
target_acc_factor = trans_am.max_acc_factor/2
|
||||
end
|
||||
self._transmission_state = transmission_state
|
||||
--minetest.chat_send_all(transmission_state)
|
||||
|
||||
--control
|
||||
accel, stop = automobiles_lib.control(self, dtime, hull_direction, longit_speed, longit_drag, later_drag, accel, target_acc_factor, trans_am.max_speed, steering_angle_max, steering_speed)
|
||||
else
|
||||
self._show_lights = false
|
||||
if self.sound_handle ~= nil then
|
||||
|
@ -10,7 +10,7 @@ trans_am.max_acc_factor = 12
|
||||
trans_am.max_fuel = 10
|
||||
trans_am.trunk_slots = 12
|
||||
trans_am.ideal_step = 0.2
|
||||
trans_am.engine_sound = "automobiles_engine"
|
||||
trans_am.engine_sound = "trans_am_engine"
|
||||
|
||||
trans_am_GAUGE_FUEL_POSITION = {x=-4,y=6.8,z=16.6}
|
||||
|
||||
|
Binary file not shown.
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
-- destroy the trans_am
|
||||
function trans_am.destroy(self, puncher)
|
||||
automobiles_lib.remove_light(self)
|
||||
@ -65,10 +63,15 @@ function trans_am.engineSoundPlay(self)
|
||||
--sound
|
||||
if self.sound_handle then minetest.sound_stop(self.sound_handle) end
|
||||
if self.object then
|
||||
local snd_pitch = 1 + ((self._longit_speed/10)/2)
|
||||
if self._transmission_state == 1 then
|
||||
snd_pitch = 1 + (self._longit_speed/10)
|
||||
end
|
||||
|
||||
self.sound_handle = minetest.sound_play({name = trans_am.engine_sound},
|
||||
{object = self.object, gain = 2,
|
||||
pitch = 1 + ((self._longit_speed/10)/2),
|
||||
max_hear_distance = 10,
|
||||
{object = self.object, gain = 4,
|
||||
pitch = snd_pitch,
|
||||
max_hear_distance = 15,
|
||||
loop = true,})
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user