more cars updated
This commit is contained in:
parent
870389bc44
commit
cf29e4fa22
@ -35,7 +35,7 @@ minetest.register_craftitem("automobiles_delorean:delorean", {
|
|||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||||
automobiles_lib.setText(ent, "Delorean")
|
automobiles_lib.setText(ent, "Delorean")
|
||||||
automobiles_lib.create_inventory(ent, delorean.trunk_slots, owner)
|
automobiles_lib.create_inventory(ent, ent._trunk_slots, owner)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ minetest.register_craftitem("automobiles_delorean:time_machine", {
|
|||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||||
automobiles_lib.setText(ent, "Delorean")
|
automobiles_lib.setText(ent, "Delorean")
|
||||||
automobiles_lib.create_inventory(ent, delorean.trunk_slots, owner)
|
automobiles_lib.create_inventory(ent, ent._trunk_slots, owner)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -423,6 +423,11 @@ minetest.register_entity("automobiles_delorean:delorean", {
|
|||||||
_delorean_type = 0,
|
_delorean_type = 0,
|
||||||
_car_gravity = -automobiles_lib.gravity,
|
_car_gravity = -automobiles_lib.gravity,
|
||||||
_is_flying = 0,
|
_is_flying = 0,
|
||||||
|
_trunk_slots = 8,
|
||||||
|
_engine_sound = "delorean_engine",
|
||||||
|
_max_fuel = 10,
|
||||||
|
_formspec_function = delorean.driver_formspec,
|
||||||
|
_destroy_function = delorean.destroy,
|
||||||
|
|
||||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||||
return minetest.serialize({
|
return minetest.serialize({
|
||||||
@ -556,7 +561,7 @@ minetest.register_entity("automobiles_delorean:delorean", {
|
|||||||
local inv = minetest.get_inventory({type = "detached", name = self._inv_id})
|
local inv = minetest.get_inventory({type = "detached", name = self._inv_id})
|
||||||
-- if the game was closed the inventories have to be made anew, instead of just reattached
|
-- if the game was closed the inventories have to be made anew, instead of just reattached
|
||||||
if not inv then
|
if not inv then
|
||||||
automobiles_lib.create_inventory(self, delorean.trunk_slots)
|
automobiles_lib.create_inventory(self, self._trunk_slots)
|
||||||
else
|
else
|
||||||
self.inv = inv
|
self.inv = inv
|
||||||
end
|
end
|
||||||
@ -664,7 +669,7 @@ minetest.register_entity("automobiles_delorean:delorean", {
|
|||||||
--self.damage = self.damage + impact --sum the impact value directly to damage meter
|
--self.damage = self.damage + impact --sum the impact value directly to damage meter
|
||||||
if self._last_time_collision_snd > 0.3 then
|
if self._last_time_collision_snd > 0.3 then
|
||||||
self._last_time_collision_snd = 0
|
self._last_time_collision_snd = 0
|
||||||
minetest.sound_play("collision", {
|
minetest.sound_play("automobiles_collision", {
|
||||||
to_player = self.driver_name,
|
to_player = self.driver_name,
|
||||||
--pos = curr_pos,
|
--pos = curr_pos,
|
||||||
--max_hear_distance = 5,
|
--max_hear_distance = 5,
|
||||||
@ -792,7 +797,7 @@ minetest.register_entity("automobiles_delorean:delorean", {
|
|||||||
self._last_engine_sound_update = self._last_engine_sound_update + dtime
|
self._last_engine_sound_update = self._last_engine_sound_update + dtime
|
||||||
if self._last_engine_sound_update > 0.300 then
|
if self._last_engine_sound_update > 0.300 then
|
||||||
self._last_engine_sound_update = 0
|
self._last_engine_sound_update = 0
|
||||||
delorean.engine_set_sound_and_animation(self, longit_speed)
|
automobiles_lib.engine_set_sound_and_animation(self, longit_speed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -850,121 +855,8 @@ minetest.register_entity("automobiles_delorean:delorean", {
|
|||||||
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(self, puncher, ttime, toolcaps, dir, damage)
|
on_punch = automobiles_lib.on_punch,
|
||||||
if not puncher or not puncher:is_player() then
|
on_rightclick = automobiles_lib.on_rightclick,
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local name = puncher:get_player_name()
|
|
||||||
--[[if self.owner and self.owner ~= name and self.owner ~= "" then return end]]--
|
|
||||||
if self.owner == nil then
|
|
||||||
self.owner = name
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.driver_name and self.driver_name ~= name then
|
|
||||||
-- do not allow other players to remove the object while there is a driver
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local is_attached = false
|
|
||||||
if puncher:get_attach() == self.driver_seat then is_attached = true end
|
|
||||||
|
|
||||||
local itmstck=puncher:get_wielded_item()
|
|
||||||
local item_name = ""
|
|
||||||
if itmstck then item_name = itmstck:get_name() end
|
|
||||||
|
|
||||||
--refuel procedure
|
|
||||||
--[[
|
|
||||||
refuel works it car is stopped and engine is off
|
|
||||||
]]--
|
|
||||||
local velocity = self.object:get_velocity()
|
|
||||||
local speed = automobiles_lib.get_hipotenuse_value(vector.new(), velocity)
|
|
||||||
if math.abs(speed) <= 0.1 then
|
|
||||||
if automobiles_lib.loadFuel(self, puncher:get_player_name(), false, delorean.max_fuel) then return end
|
|
||||||
end
|
|
||||||
-- end refuel
|
|
||||||
|
|
||||||
if is_attached == false then
|
|
||||||
|
|
||||||
-- deal with painting or destroying
|
|
||||||
if itmstck then
|
|
||||||
--race status restart
|
|
||||||
if item_name == "checkpoints:status_restarter" and self._engine_running == false then
|
|
||||||
--restart race current status
|
|
||||||
self._last_checkpoint = ""
|
|
||||||
self._total_laps = -1
|
|
||||||
self._race_id = ""
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if automobiles_lib.set_paint(self, puncher, itmstck) == false then
|
|
||||||
local is_admin = false
|
|
||||||
is_admin = minetest.check_player_privs(puncher, {server=true})
|
|
||||||
--minetest.chat_send_all('owner '.. self.owner ..' - name '.. name)
|
|
||||||
if not self.driver and (self.owner == name or is_admin == true) and toolcaps and
|
|
||||||
toolcaps.damage_groups and toolcaps.damage_groups.fleshy then
|
|
||||||
self.hp = self.hp - 10
|
|
||||||
minetest.sound_play("collision", {
|
|
||||||
object = self.object,
|
|
||||||
max_hear_distance = 5,
|
|
||||||
gain = 1.0,
|
|
||||||
fade = 0.0,
|
|
||||||
pitch = 1.0,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.hp <= 0 then
|
|
||||||
delorean.destroy(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
|
||||||
if not clicker or not clicker:is_player() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local name = clicker:get_player_name()
|
|
||||||
--[[if self.owner and self.owner ~= name and self.owner ~= "" then return end]]--
|
|
||||||
if self.owner == "" then
|
|
||||||
self.owner = name
|
|
||||||
end
|
|
||||||
|
|
||||||
if name == self.driver_name then
|
|
||||||
delorean.driver_formspec(name)
|
|
||||||
else
|
|
||||||
if name == self.owner then
|
|
||||||
if clicker:get_player_control().aux1 == true then
|
|
||||||
automobiles_lib.show_vehicle_trunk_formspec(self, clicker, delorean.trunk_slots)
|
|
||||||
else
|
|
||||||
--is the owner, okay, lets attach
|
|
||||||
automobiles_lib.attach_driver(self, clicker)
|
|
||||||
-- sound
|
|
||||||
self.sound_handle = minetest.sound_play({name = delorean.engine_sound},
|
|
||||||
{object = self.object, gain = 1.5, pitch = 1, max_hear_distance = 30, loop = true,})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
--minetest.chat_send_all("clicou")
|
|
||||||
--a passenger
|
|
||||||
if self._passenger == nil then
|
|
||||||
--there is no passenger, so lets attach
|
|
||||||
if self.driver_name then
|
|
||||||
automobiles_lib.attach_pax(self, clicker, true)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
--there is a passeger
|
|
||||||
if self._passenger == name then
|
|
||||||
--if you are the psenger, so deattach
|
|
||||||
automobiles_lib.dettach_pax(self, clicker)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,10 +7,7 @@ delorean.LATER_DRAG_FACTOR = 8.0
|
|||||||
delorean.gravity = automobiles_lib.gravity
|
delorean.gravity = automobiles_lib.gravity
|
||||||
delorean.max_speed = 30
|
delorean.max_speed = 30
|
||||||
delorean.max_acc_factor = 8
|
delorean.max_acc_factor = 8
|
||||||
delorean.max_fuel = 10
|
|
||||||
delorean.trunk_slots = 8
|
|
||||||
delorean.ideal_step = 0.2
|
delorean.ideal_step = 0.2
|
||||||
delorean.engine_sound = "delorean_engine"
|
|
||||||
|
|
||||||
DELOREAN_GAUGE_FUEL_POSITION = {x=-4.66,y=6.2,z=17.9}
|
DELOREAN_GAUGE_FUEL_POSITION = {x=-4.66,y=6.2,z=17.9}
|
||||||
|
|
||||||
@ -21,11 +18,11 @@ dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "custom_physics.l
|
|||||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "fuel_management.lua")
|
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "fuel_management.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "ground_detection.lua")
|
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "ground_detection.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua")
|
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua")
|
||||||
|
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "forms.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "control.lua")
|
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "control.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "flight.lua")
|
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "flight.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "utilities.lua")
|
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "utilities.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "entities.lua")
|
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "entities.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "forms.lua")
|
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "crafts.lua")
|
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "crafts.lua")
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@ roadster.LATER_DRAG_FACTOR = 30.0
|
|||||||
roadster.gravity = automobiles_lib.gravity
|
roadster.gravity = automobiles_lib.gravity
|
||||||
roadster.max_speed = 12
|
roadster.max_speed = 12
|
||||||
roadster.max_acc_factor = 5
|
roadster.max_acc_factor = 5
|
||||||
roadster.max_fuel = 10
|
|
||||||
roadster.trunk_slots = 8
|
|
||||||
|
|
||||||
ROADSTER_GAUGE_FUEL_POSITION = {x=0,y=8.04,z=17.84}
|
ROADSTER_GAUGE_FUEL_POSITION = {x=0,y=8.04,z=17.84}
|
||||||
|
|
||||||
@ -19,9 +17,9 @@ dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "custom_physics.l
|
|||||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua")
|
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "fuel_management.lua")
|
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "fuel_management.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "ground_detection.lua")
|
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "ground_detection.lua")
|
||||||
|
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_forms.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_utilities.lua")
|
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_utilities.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_entities.lua")
|
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_entities.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_forms.lua")
|
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_crafts.lua")
|
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_crafts.lua")
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ minetest.register_craftitem("automobiles_roadster:roadster", {
|
|||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||||
automobiles_lib.setText(ent, "Roadster")
|
automobiles_lib.setText(ent, "Roadster")
|
||||||
automobiles_lib.create_inventory(ent, roadster.trunk_slots, owner)
|
automobiles_lib.create_inventory(ent, ent._trunk_slots, owner)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -277,6 +277,11 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
_inv_id = "",
|
_inv_id = "",
|
||||||
_change_color = automobiles_lib.paint,
|
_change_color = automobiles_lib.paint,
|
||||||
_intensity = 4,
|
_intensity = 4,
|
||||||
|
_trunk_slots = 8,
|
||||||
|
_engine_sound = "roadster_engine",
|
||||||
|
_max_fuel = 10,
|
||||||
|
_formspec_function = roadster.driver_formspec,
|
||||||
|
_destroy_function = roadster.destroy,
|
||||||
|
|
||||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||||
return minetest.serialize({
|
return minetest.serialize({
|
||||||
@ -396,7 +401,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
local inv = minetest.get_inventory({type = "detached", name = self._inv_id})
|
local inv = minetest.get_inventory({type = "detached", name = self._inv_id})
|
||||||
-- if the game was closed the inventories have to be made anew, instead of just reattached
|
-- if the game was closed the inventories have to be made anew, instead of just reattached
|
||||||
if not inv then
|
if not inv then
|
||||||
automobiles_lib.create_inventory(self, roadster.trunk_slots)
|
automobiles_lib.create_inventory(self, self._trunk_slots)
|
||||||
else
|
else
|
||||||
self.inv = inv
|
self.inv = inv
|
||||||
end
|
end
|
||||||
@ -582,7 +587,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
self._last_engine_sound_update = self._last_engine_sound_update + dtime
|
self._last_engine_sound_update = self._last_engine_sound_update + dtime
|
||||||
if self._last_engine_sound_update > 0.300 then
|
if self._last_engine_sound_update > 0.300 then
|
||||||
self._last_engine_sound_update = 0
|
self._last_engine_sound_update = 0
|
||||||
roadster.engine_set_sound_and_animation(self, longit_speed)
|
automobiles_lib.engine_set_sound_and_animation(self, longit_speed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -618,121 +623,8 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_punch = function(self, puncher, ttime, toolcaps, dir, damage)
|
on_punch = automobiles_lib.on_punch,
|
||||||
if not puncher or not puncher:is_player() then
|
on_rightclick = automobiles_lib.on_rightclick,
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local name = puncher:get_player_name()
|
|
||||||
--[[if self.owner and self.owner ~= name and self.owner ~= "" then return end]]--
|
|
||||||
if self.owner == nil then
|
|
||||||
self.owner = name
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.driver_name and self.driver_name ~= name then
|
|
||||||
-- do not allow other players to remove the object while there is a driver
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local is_attached = false
|
|
||||||
if puncher:get_attach() == self.driver_seat then is_attached = true end
|
|
||||||
|
|
||||||
local itmstck=puncher:get_wielded_item()
|
|
||||||
local item_name = ""
|
|
||||||
if itmstck then item_name = itmstck:get_name() end
|
|
||||||
|
|
||||||
--refuel procedure
|
|
||||||
--[[
|
|
||||||
refuel works it car is stopped and engine is off
|
|
||||||
]]--
|
|
||||||
local velocity = self.object:get_velocity()
|
|
||||||
local speed = automobiles_lib.get_hipotenuse_value(vector.new(), velocity)
|
|
||||||
if math.abs(speed) <= 0.1 then
|
|
||||||
if automobiles_lib.loadFuel(self, puncher:get_player_name(), false, roadster.max_fuel) then return end
|
|
||||||
end
|
|
||||||
-- end refuel
|
|
||||||
|
|
||||||
if is_attached == false then
|
|
||||||
|
|
||||||
-- deal with painting or destroying
|
|
||||||
if itmstck then
|
|
||||||
--race status restart
|
|
||||||
if item_name == "checkpoints:status_restarter" and self._engine_running == false then
|
|
||||||
--restart race current status
|
|
||||||
self._last_checkpoint = ""
|
|
||||||
self._total_laps = -1
|
|
||||||
self._race_id = ""
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if automobiles_lib.set_paint(self, puncher, itmstck) == false then
|
|
||||||
local is_admin = false
|
|
||||||
is_admin = minetest.check_player_privs(puncher, {server=true})
|
|
||||||
--minetest.chat_send_all('owner '.. self.owner ..' - name '.. name)
|
|
||||||
if not self.driver and (self.owner == name or is_admin == true) and toolcaps and
|
|
||||||
toolcaps.damage_groups and toolcaps.damage_groups.fleshy then
|
|
||||||
self.hp = self.hp - 10
|
|
||||||
minetest.sound_play("collision", {
|
|
||||||
object = self.object,
|
|
||||||
max_hear_distance = 5,
|
|
||||||
gain = 1.0,
|
|
||||||
fade = 0.0,
|
|
||||||
pitch = 1.0,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.hp <= 0 then
|
|
||||||
roadster.destroy(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
|
||||||
if not clicker or not clicker:is_player() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local name = clicker:get_player_name()
|
|
||||||
--[[if self.owner and self.owner ~= name and self.owner ~= "" then return end]]--
|
|
||||||
if self.owner == "" then
|
|
||||||
self.owner = name
|
|
||||||
end
|
|
||||||
|
|
||||||
if name == self.driver_name then
|
|
||||||
roadster.driver_formspec(name)
|
|
||||||
else
|
|
||||||
if name == self.owner then
|
|
||||||
if clicker:get_player_control().aux1 == true then
|
|
||||||
automobiles_lib.show_vehicle_trunk_formspec(self, clicker, roadster.trunk_slots)
|
|
||||||
else
|
|
||||||
--is the owner, okay, lets attach
|
|
||||||
automobiles_lib.attach_driver(self, clicker)
|
|
||||||
-- sound
|
|
||||||
self.sound_handle = minetest.sound_play({name = "roadster_engine"},
|
|
||||||
{object = self.object, gain = 0.5, pitch = 0.6, max_hear_distance = 30, loop = true,})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
--minetest.chat_send_all("clicou")
|
|
||||||
--a passenger
|
|
||||||
if self._passenger == nil then
|
|
||||||
--there is no passenger, so lets attach
|
|
||||||
if self.driver_name then
|
|
||||||
automobiles_lib.attach_pax(self, clicker, true)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
--there is a passeger
|
|
||||||
if self._passenger == name then
|
|
||||||
--if you are the psenger, so deattach
|
|
||||||
automobiles_lib.dettach_pax(self, clicker)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,20 +1,7 @@
|
|||||||
|
|
||||||
--------------
|
|
||||||
-- Manual --
|
|
||||||
--------------
|
|
||||||
|
|
||||||
function roadster.getCarFromPlayer(player)
|
|
||||||
local seat = player:get_attach()
|
|
||||||
if seat then
|
|
||||||
local car = seat:get_attach()
|
|
||||||
return car
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function roadster.driver_formspec(name)
|
function roadster.driver_formspec(name)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
local vehicle_obj = roadster.getCarFromPlayer(player)
|
local vehicle_obj = automobiles_lib.getCarFromPlayer(player)
|
||||||
if vehicle_obj == nil then
|
if vehicle_obj == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -39,7 +26,7 @@ end
|
|||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname == "roadster:driver_main" then
|
if formname == "roadster:driver_main" then
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local car_obj = roadster.getCarFromPlayer(player)
|
local car_obj = automobiles_lib.getCarFromPlayer(player)
|
||||||
if car_obj then
|
if car_obj then
|
||||||
local ent = car_obj:get_luaentity()
|
local ent = car_obj:get_luaentity()
|
||||||
if ent then
|
if ent then
|
||||||
|
@ -53,24 +53,3 @@ function roadster.destroy(self, puncher)
|
|||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_roadster:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_roadster:wheel')
|
||||||
end
|
end
|
||||||
|
|
||||||
function roadster.engine_set_sound_and_animation(self, _longit_speed)
|
|
||||||
--minetest.chat_send_all('test1 ' .. dump(self._engine_running) )
|
|
||||||
if self.sound_handle then
|
|
||||||
if (math.abs(self._longit_speed) > math.abs(_longit_speed) + 0.08) or (math.abs(self._longit_speed) + 0.08 < math.abs(_longit_speed)) then
|
|
||||||
--minetest.chat_send_all('test2')
|
|
||||||
roadster.engineSoundPlay(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function roadster.engineSoundPlay(self)
|
|
||||||
--sound
|
|
||||||
if self.sound_handle then minetest.sound_stop(self.sound_handle) end
|
|
||||||
if self.object then
|
|
||||||
self.sound_handle = minetest.sound_play({name = "roadster_engine"},
|
|
||||||
{object = self.object, gain = 0.5,
|
|
||||||
pitch = 0.6 + ((self._longit_speed/10)/2),
|
|
||||||
max_hear_distance = 10,
|
|
||||||
loop = true,})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user