diff --git a/automobiles_delorean/entities.lua b/automobiles_delorean/entities.lua index e352adc..00d0bbd 100755 --- a/automobiles_delorean/entities.lua +++ b/automobiles_delorean/entities.lua @@ -78,20 +78,12 @@ initial_properties = { "automobiles_black.png", --conductors "automobiles_black.png", --ok "automobiles_delorean_brass.png", --ok - "automobiles_metal.png", --time panel - "automobiles_delorean_time.png", --time panel "automobiles_metal.png", --base circuit switch "automobiles_red.png", --red button "automobiles_dark_grey.png", --ok "automobiles_delorean_brass.png", --ok "automobiles_black.png", --electric switch - "automobiles_metal.png", -- flux capacitor - "automobiles_delorean_flux.png", --flux capacitor - "automobiles_black.png", --flux capacitor "automobiles_dark_grey.png", --base - "automobiles_dark_grey.png", --roof panel - "automobiles_delorean_roof_1.png", --root panel - "automobiles_delorean_roof_2.png", --roof panel "automobiles_metal.png", --f bump "automobiles_dark_grey.png", --f bump "automobiles_metal.png"}, @@ -113,6 +105,42 @@ initial_properties = { }) +minetest.register_entity('automobiles_delorean:time_machine_kit_instruments',{ + initial_properties = { + physical = true, + collide_with_objects=true, + collisionbox = {-0.5, 0, -0.5, 0.5, 1, 0.5}, + pointable=false, + visual = "mesh", + mesh = "automobiles_delorean_time_machine_instruments.b3d", + textures = { + "automobiles_metal.png", --time panel + "automobiles_delorean_time.png", --time panel + "automobiles_metal.png", -- flux capacitor + "automobiles_delorean_flux.png", --flux capacitor + "automobiles_black.png", --flux capacitor + "automobiles_dark_grey.png", --roof panel + "automobiles_delorean_roof_1.png", --root panel + "automobiles_delorean_roof_2.png", --roof panel + }, + }, + + on_activate = function(self,std) + self.sdata = minetest.deserialize(std) or {} + if self.sdata.remove then self.object:remove() end + end, + + get_staticdata=function(self) + self.sdata.remove=true + return minetest.serialize(self.sdata) + end, + + --[[on_step = function(self, dtime, moveresult) + minetest.chat_send_all(dump(moveresult)) + end,]]-- + +}) + minetest.register_entity('automobiles_delorean:front_suspension',{ initial_properties = { @@ -583,41 +611,8 @@ minetest.register_entity("automobiles_delorean:delorean", { end end - --to fix the load on first time - if self._delorean_type == 1 then - local ent_propertioes = self.normal_kit:get_properties() - if ent_propertioes.mesh ~= "automobiles_delorean_time_machine_accessories.b3d" then - delorean.set_kit(self) - end - --start flight functions - if self._is_flying == 1 then - if is_attached then - delorean.control_flight(self, player) - end - delorean.gravity_auto_correction(self, dtime) - - --check if is near the ground, so revert the flight mode - local noded = automobiles_lib.nodeatpos(automobiles_lib.pos_shift(curr_pos,{y=-0.6})) - if (noded and noded.drawtype ~= 'airlike') then - if noded.drawtype ~= 'liquid' then - self._is_flying = 0 - end - --avoid liquids - if noded.drawtype == 'liquid' then - self._car_gravity = 5 - local fixed_vel = velocity - fixed_vel.y = 0.1 - self.lastvelocity.y = fixed_vel.y --do not compute collision after - self.object:set_velocity(fixed_vel) - --curr_pos.y = curr_pos.y + 0.5 - --self.object:move_to(curr_pos) - end - end - - else - self._car_gravity = -automobiles_lib.gravity - end - end + --to fix the load on first time and turn on the lights of time machine + delorean.set_mode(self, is_attached, curr_pos, velocity, player, dtime) local is_breaking = false if is_attached then @@ -949,8 +944,8 @@ minetest.register_entity("automobiles_delorean:delorean", { --is the owner, okay, lets attach automobiles_lib.attach_driver(self, clicker) -- sound - self.sound_handle = minetest.sound_play({name = "automobiles_engine"}, - {object = self.object, gain = 4, pitch = 1, max_hear_distance = 30, loop = true,}) + 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") diff --git a/automobiles_delorean/flight.lua b/automobiles_delorean/flight.lua index 81a2a18..5fe6a8e 100644 --- a/automobiles_delorean/flight.lua +++ b/automobiles_delorean/flight.lua @@ -13,6 +13,11 @@ function delorean.set_kit(self) normal_kit:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0}) self.normal_kit = normal_kit self.normal_kit:set_properties({is_visible=true}) + + local instruments = minetest.add_entity(pos,'automobiles_delorean:time_machine_kit_instruments') + instruments:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0}) + self.instruments = instruments + self.instruments:set_properties({is_visible=true}) end end @@ -89,3 +94,68 @@ function delorean.turn_flight_mode(self) end end +function delorean.set_mode(self, is_attached, curr_pos, velocity, player, dtime) + if self._delorean_type == 1 then + local ent_propertioes = self.normal_kit:get_properties() + if ent_propertioes.mesh ~= "automobiles_delorean_time_machine_accessories.b3d" then + delorean.set_kit(self) + end + + if is_attached == true then + self.instruments:set_properties( + { + textures={ + "automobiles_metal.png", --time panel + "automobiles_delorean_time.png", --time panel + "automobiles_metal.png", -- flux capacitor + "automobiles_delorean_flux.png", --flux capacitor + "automobiles_black.png", --flux capacitor + "automobiles_dark_grey.png", --roof panel + "automobiles_delorean_roof_1.png", --root panel + "automobiles_delorean_roof_2.png", --roof panel + }, glow=15} + ) + else + self.instruments:set_properties( + { + textures={ + "automobiles_metal.png", --time panel + "automobiles_delorean_time_off.png", --time panel + "automobiles_metal.png", -- flux capacitor + "automobiles_delorean_flux_off.png", --flux capacitor + "automobiles_black.png", --flux capacitor + "automobiles_dark_grey.png", --roof panel + "automobiles_delorean_roof_1_off.png", --root panel + "automobiles_delorean_roof_2_off.png", --roof panel + }, glow=0} + ) + end + + --start flight functions + if self._is_flying == 1 then + if is_attached then + delorean.control_flight(self, player) + end + delorean.gravity_auto_correction(self, dtime) + + --check if is near the ground, so revert the flight mode + local noded = automobiles_lib.nodeatpos(automobiles_lib.pos_shift(curr_pos,{y=-0.6})) + if (noded and noded.drawtype ~= 'airlike') then + if noded.drawtype ~= 'liquid' then + self._is_flying = 0 + end + --avoid liquids + if noded.drawtype == 'liquid' then + self._car_gravity = 5 + local fixed_vel = velocity + fixed_vel.y = 0.1 + self.lastvelocity.y = fixed_vel.y --do not compute collision after + self.object:set_velocity(fixed_vel) + --curr_pos.y = curr_pos.y + 0.5 + --self.object:move_to(curr_pos) + end + end + end + end +end + diff --git a/automobiles_delorean/init.lua b/automobiles_delorean/init.lua index 1a4026e..7e6b0e8 100755 --- a/automobiles_delorean/init.lua +++ b/automobiles_delorean/init.lua @@ -10,6 +10,7 @@ delorean.max_acc_factor = 8 delorean.max_fuel = 10 delorean.trunk_slots = 8 delorean.ideal_step = 0.2 +delorean.engine_sound = "delorean_engine" DELOREAN_GAUGE_FUEL_POSITION = {x=-4.66,y=6.2,z=17.9} diff --git a/automobiles_delorean/models/automobiles_delorean_time_machine_accessories.b3d b/automobiles_delorean/models/automobiles_delorean_time_machine_accessories.b3d index ceedb88..ee289f9 100755 Binary files a/automobiles_delorean/models/automobiles_delorean_time_machine_accessories.b3d and b/automobiles_delorean/models/automobiles_delorean_time_machine_accessories.b3d differ diff --git a/automobiles_delorean/models/automobiles_delorean_time_machine_instruments.b3d b/automobiles_delorean/models/automobiles_delorean_time_machine_instruments.b3d new file mode 100755 index 0000000..e1911d6 Binary files /dev/null and b/automobiles_delorean/models/automobiles_delorean_time_machine_instruments.b3d differ diff --git a/automobiles_delorean/sounds/delorean_engine.ogg b/automobiles_delorean/sounds/delorean_engine.ogg index 3284d80..ff6c329 100644 Binary files a/automobiles_delorean/sounds/delorean_engine.ogg and b/automobiles_delorean/sounds/delorean_engine.ogg differ diff --git a/automobiles_delorean/textures/automobiles_delorean_flux.png b/automobiles_delorean/textures/automobiles_delorean_flux.png index ffb1e7c..7ca8a8d 100755 Binary files a/automobiles_delorean/textures/automobiles_delorean_flux.png and b/automobiles_delorean/textures/automobiles_delorean_flux.png differ diff --git a/automobiles_delorean/textures/automobiles_delorean_flux_off.png b/automobiles_delorean/textures/automobiles_delorean_flux_off.png new file mode 100644 index 0000000..37d72a9 Binary files /dev/null and b/automobiles_delorean/textures/automobiles_delorean_flux_off.png differ diff --git a/automobiles_delorean/textures/automobiles_delorean_roof_1_off.png b/automobiles_delorean/textures/automobiles_delorean_roof_1_off.png new file mode 100644 index 0000000..d939742 Binary files /dev/null and b/automobiles_delorean/textures/automobiles_delorean_roof_1_off.png differ diff --git a/automobiles_delorean/textures/automobiles_delorean_roof_2_off.png b/automobiles_delorean/textures/automobiles_delorean_roof_2_off.png new file mode 100644 index 0000000..f5e00eb Binary files /dev/null and b/automobiles_delorean/textures/automobiles_delorean_roof_2_off.png differ diff --git a/automobiles_delorean/textures/automobiles_delorean_time_off.png b/automobiles_delorean/textures/automobiles_delorean_time_off.png new file mode 100644 index 0000000..0570d12 Binary files /dev/null and b/automobiles_delorean/textures/automobiles_delorean_time_off.png differ diff --git a/automobiles_delorean/utilities.lua b/automobiles_delorean/utilities.lua index de04009..be18cb5 100755 --- a/automobiles_delorean/utilities.lua +++ b/automobiles_delorean/utilities.lua @@ -37,6 +37,7 @@ function delorean.destroy(self, puncher) if self.r_lights then self.r_lights:remove() end if self.reverse_lights then self.reverse_lights:remove() end if self.normal_kit then self.normal_kit:remove() end + if self.instruments then self.instruments:remove() end if self.turn_l_light then self.turn_l_light:remove() end if self.turn_r_light then self.turn_r_light:remove() end @@ -67,8 +68,8 @@ function delorean.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 = "automobiles_engine"}, - {object = self.object, gain = 8, + self.sound_handle = minetest.sound_play({name = delorean.engine_sound}, + {object = self.object, gain = 2, pitch = 1 + ((self._longit_speed/10)/2), max_hear_distance = 10, loop = true,})