mirror of
https://github.com/APercy/automobiles_pck
synced 2025-02-09 16:13:51 +00:00
return of original coupe. Delorean is now a new car
This commit is contained in:
parent
54ae64d283
commit
eed3796736
35
automobiles_coupe/coupe_crafts.lua
Normal file → Executable file
35
automobiles_coupe/coupe_crafts.lua
Normal file → Executable file
@ -29,41 +29,6 @@ minetest.register_craftitem("automobiles_coupe:coupe", {
|
||||
local owner = placer:get_player_name()
|
||||
if ent then
|
||||
ent.owner = owner
|
||||
ent._coupe_type = 0
|
||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||
car:set_yaw(placer:get_look_horizontal())
|
||||
itemstack:take_item()
|
||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||
automobiles_lib.setText(ent, "Coupe")
|
||||
automobiles_lib.create_inventory(ent, coupe.trunk_slots, owner)
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
-- coupe
|
||||
minetest.register_craftitem("automobiles_coupe:time_machine", {
|
||||
description = S("Time Machine"),
|
||||
inventory_image = "automobiles_coupe.png",
|
||||
liquids_pointable = false,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local pointed_pos = pointed_thing.above
|
||||
--pointed_pos.y=pointed_pos.y+0.2
|
||||
local car = minetest.add_entity(pointed_pos, "automobiles_coupe:coupe")
|
||||
if car and placer then
|
||||
local ent = car:get_luaentity()
|
||||
local owner = placer:get_player_name()
|
||||
if ent then
|
||||
ent.owner = owner
|
||||
ent._coupe_type = 1
|
||||
--minetest.chat_send_all("coupe: " .. ent._coupe_type)
|
||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||
car:set_yaw(placer:get_look_horizontal())
|
||||
itemstack:take_item()
|
||||
|
@ -1,8 +1,7 @@
|
||||
--
|
||||
-- entity
|
||||
--
|
||||
|
||||
local old_entities = {"automobiles_coupe:steering"}
|
||||
local old_entities = {"automobiles_coupe:time_machine_kit", "automobiles_coupe:wheel"}
|
||||
for _,entity_name in ipairs(old_entities) do
|
||||
minetest.register_entity(":"..entity_name, {
|
||||
on_activate = function(self, staticdata)
|
||||
@ -11,117 +10,6 @@ for _,entity_name in ipairs(old_entities) do
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_entity('automobiles_coupe:wheel',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_coupe_wheel.b3d",
|
||||
backface_culling = false,
|
||||
textures = {"automobiles_black.png", "automobiles_metal.png", "automobiles_coupe_wheel.png"},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_coupe:normal_kit',{
|
||||
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_coupe_normal_kit.b3d",
|
||||
textures = {"automobiles_black.png","automobiles_coupe_glasses.png"},
|
||||
},
|
||||
|
||||
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_coupe:time_machine_kit',{
|
||||
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_coupe_time_machine_accessories.b3d",
|
||||
textures = {
|
||||
"automobiles_metal.png", --ok
|
||||
"automobiles_black.png", --ok
|
||||
"automobiles_dark_grey.png", --exausts
|
||||
"automobiles_black.png", --exausts
|
||||
"automobiles_metal.png", --energy base collector
|
||||
"automobiles_painting.png^[multiply:#0063b0", --capacitors
|
||||
"automobiles_black.png", --arc
|
||||
"automobiles_painting.png^[multiply:#07B6BC", --capacitors
|
||||
"automobiles_black.png", --base mr fusion
|
||||
"automobiles_painting.png", --mr fusion
|
||||
"automobiles_metal.png", --ok
|
||||
"automobiles_painting.png", --ok
|
||||
"automobiles_black.png", --ok
|
||||
"automobiles_metal.png", --lateral tubes
|
||||
"automobiles_black.png", --conductors
|
||||
"automobiles_black.png", --ok
|
||||
"automobiles_coupe_brass.png", --ok
|
||||
"automobiles_metal.png", --time panel
|
||||
"automobiles_coupe_time.png", --time panel
|
||||
"automobiles_metal.png", --base circuit switch
|
||||
"automobiles_red.png", --red button
|
||||
"automobiles_dark_grey.png", --ok
|
||||
"automobiles_coupe_brass.png", --ok
|
||||
"automobiles_black.png", --electric switch
|
||||
"automobiles_metal.png", -- flux capacitor
|
||||
"automobiles_coupe_flux.png", --flux capacitor
|
||||
"automobiles_black.png", --flux capacitor
|
||||
"automobiles_dark_grey.png", --base
|
||||
"automobiles_dark_grey.png", --roof panel
|
||||
"automobiles_coupe_roof_1.png", --root panel
|
||||
"automobiles_coupe_roof_2.png", --roof panel
|
||||
"automobiles_metal.png", --f bump
|
||||
"automobiles_dark_grey.png", --f bump
|
||||
"automobiles_metal.png"},
|
||||
},
|
||||
|
||||
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_coupe:front_suspension',{
|
||||
initial_properties = {
|
||||
@ -180,7 +68,7 @@ initial_properties = {
|
||||
glow = 0,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_coupe_f_lights.b3d",
|
||||
textures = {"automobiles_grey.png", "automobiles_black.png"},
|
||||
textures = {"automobiles_grey.png",},
|
||||
},
|
||||
|
||||
on_activate = function(self,std)
|
||||
@ -203,7 +91,7 @@ initial_properties = {
|
||||
glow = 0,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_coupe_rear_pos_lights.b3d",
|
||||
textures = {"automobiles_rear_lights_off.png"},
|
||||
textures = {"automobiles_rear_lights_off.png",},
|
||||
},
|
||||
|
||||
on_activate = function(self,std)
|
||||
@ -309,6 +197,28 @@ initial_properties = {
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_coupe:steering',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_coupe_drive_wheel.b3d",
|
||||
textures = {"automobiles_black.png", "automobiles_black.png", "automobiles_black.png"},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_coupe:pointer',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
@ -331,24 +241,6 @@ initial_properties = {
|
||||
end,
|
||||
})
|
||||
|
||||
local function set_kit(self)
|
||||
local normal_kit = nil
|
||||
if self.normal_kit then self.normal_kit:remove() end
|
||||
local pos = self.object:get_pos()
|
||||
if self._coupe_type == 0 or self._coupe_type == nil then
|
||||
normal_kit = minetest.add_entity(pos,'automobiles_coupe:normal_kit')
|
||||
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})
|
||||
elseif self._coupe_type == 1 then
|
||||
--time machine
|
||||
normal_kit = minetest.add_entity(pos,'automobiles_coupe:time_machine_kit')
|
||||
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})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity("automobiles_coupe:coupe", {
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
@ -361,26 +253,16 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
--use_texture_alpha = true,
|
||||
--backface_culling = false,
|
||||
textures = {
|
||||
"automobiles_dark_grey.png", --bancos
|
||||
"automobiles_painting.png", --pintura portas
|
||||
"automobiles_black.png", --retrovisores
|
||||
"automobiles_dark_grey.png", --forro da porta
|
||||
"automobiles_coupe_glasses.png", --vidros das portas
|
||||
"automobiles_metal.png", --espelhos
|
||||
"automobiles_black.png", --volante
|
||||
"automobiles_painting2.png", --face
|
||||
"automobiles_black.png", --moldura parabrisa
|
||||
"automobiles_coupe_glasses.png", --parabrisa
|
||||
"automobiles_black.png", --grade_motor
|
||||
"automobiles_dark_grey.png", --revestimento interno
|
||||
"automobiles_coupe_fuel.png", --combustivel
|
||||
"automobiles_painting.png", --pintura
|
||||
"automobiles_black.png", --frisos
|
||||
"automobiles_black.png", --bancos
|
||||
"automobiles_painting.png", --carroceria
|
||||
"automobiles_black.png", --paralamas
|
||||
"automobiles_black.png", --assoalho
|
||||
"automobiles_painting2.png", --traseira
|
||||
"automobiles_black.png", --traseira placa
|
||||
"automobiles_black.png", --ventilação vidro traseiro
|
||||
"automobiles_black.png", --saia
|
||||
"automobiles_black.png", --banco
|
||||
"automobiles_coupe_glasses.png", --vidros
|
||||
"automobiles_black.png", --aletas vidro traseiro
|
||||
"automobiles_grey.png", --interior
|
||||
"automobiles_black.png", --panel
|
||||
"automobiles_coupe_fuel.png",
|
||||
},
|
||||
},
|
||||
textures = {},
|
||||
@ -395,7 +277,7 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
lastvelocity = vector.new(),
|
||||
time_total = 0,
|
||||
_passenger = nil,
|
||||
_color = "#9f9f9f",
|
||||
_color = "#6d6d6d",
|
||||
_steering_angle = 0,
|
||||
_engine_running = false,
|
||||
_last_checkpoint = "",
|
||||
@ -419,7 +301,6 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
_inv_id = "",
|
||||
_change_color = automobiles_lib.paint,
|
||||
_intensity = 4,
|
||||
_coupe_type = 0,
|
||||
|
||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||
return minetest.serialize({
|
||||
@ -436,7 +317,6 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
stored_pitch = self._pitch,
|
||||
stored_light_old_pos = self._light_old_pos,
|
||||
stored_inv_id = self._inv_id,
|
||||
stored_coupe_type = self._coupe_type,
|
||||
})
|
||||
end,
|
||||
|
||||
@ -461,7 +341,6 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
self._pitch = data.stored_pitch
|
||||
self._light_old_pos = data.stored_light_old_pos
|
||||
self._inv_id = data.stored_inv_id
|
||||
self._coupe_type = data.stored_coupe_type
|
||||
automobiles_lib.setText(self, "Coupe")
|
||||
end
|
||||
|
||||
@ -471,16 +350,16 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
local front_suspension=minetest.add_entity(self.object:get_pos(),'automobiles_coupe:front_suspension')
|
||||
front_suspension:set_attach(self.object,'',{x=0,y=1.5,z=27.7057},{x=0,y=0,z=0})
|
||||
front_suspension:set_attach(self.object,'',{x=0,y=1.5,z=24.5},{x=0,y=0,z=0})
|
||||
self.front_suspension = front_suspension
|
||||
|
||||
local lf_wheel=minetest.add_entity(pos,'automobiles_coupe:wheel')
|
||||
local lf_wheel=minetest.add_entity(pos,'automobiles_lib:wheel')
|
||||
lf_wheel:set_attach(self.front_suspension,'',{x=-coupe.front_wheel_xpos,y=0,z=0},{x=0,y=0,z=0})
|
||||
-- set the animation once and later only change the speed
|
||||
lf_wheel:set_animation({x = 1, y = 49}, 0, 0, true)
|
||||
self.lf_wheel = lf_wheel
|
||||
|
||||
local rf_wheel=minetest.add_entity(pos,'automobiles_coupe:wheel')
|
||||
local rf_wheel=minetest.add_entity(pos,'automobiles_lib:wheel')
|
||||
rf_wheel:set_attach(self.front_suspension,'',{x=coupe.front_wheel_xpos,y=0,z=0},{x=0,y=180,z=0})
|
||||
-- set the animation once and later only change the speed
|
||||
rf_wheel:set_animation({x = 1, y = 49}, 0, 0, true)
|
||||
@ -490,26 +369,32 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
rear_suspension:set_attach(self.object,'',{x=0,y=1.5,z=0},{x=0,y=0,z=0})
|
||||
self.rear_suspension = rear_suspension
|
||||
|
||||
local lr_wheel=minetest.add_entity(pos,'automobiles_coupe:wheel')
|
||||
local lr_wheel=minetest.add_entity(pos,'automobiles_lib:wheel')
|
||||
lr_wheel:set_attach(self.rear_suspension,'',{x=-coupe.rear_wheel_xpos,y=0,z=0},{x=0,y=0,z=0})
|
||||
-- set the animation once and later only change the speed
|
||||
lr_wheel:set_animation({x = 1, y = 49}, 0, 0, true)
|
||||
self.lr_wheel = lr_wheel
|
||||
|
||||
local rr_wheel=minetest.add_entity(pos,'automobiles_coupe:wheel')
|
||||
local rr_wheel=minetest.add_entity(pos,'automobiles_lib:wheel')
|
||||
rr_wheel:set_attach(self.rear_suspension,'',{x=coupe.rear_wheel_xpos,y=0,z=0},{x=0,y=180,z=0})
|
||||
-- set the animation once and later only change the speed
|
||||
rr_wheel:set_animation({x = 1, y = 49}, 0, 0, true)
|
||||
self.rr_wheel = rr_wheel
|
||||
|
||||
self.object:set_bone_position("drive_adjust", {x=-4.66, y=6.31, z=15.69}, {x=15, y=0, z=0})
|
||||
local steering_axis=minetest.add_entity(pos,'automobiles_coupe:pivot_mesh')
|
||||
steering_axis:set_attach(self.object,'',{x=-4.26,y=6.01,z=14.18},{x=15,y=0,z=0})
|
||||
self.steering_axis = steering_axis
|
||||
|
||||
local steering=minetest.add_entity(self.steering_axis:get_pos(),'automobiles_coupe:steering')
|
||||
steering:set_attach(self.steering_axis,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.steering = steering
|
||||
|
||||
local driver_seat=minetest.add_entity(pos,'automobiles_coupe:pivot_mesh')
|
||||
driver_seat:set_attach(self.object,'',{x=-4.65,y=0.48,z=9.5},{x=0,y=0,z=0})
|
||||
driver_seat:set_attach(self.object,'',{x=-4.25,y=0.48,z=9.5},{x=0,y=0,z=0})
|
||||
self.driver_seat = driver_seat
|
||||
|
||||
local passenger_seat=minetest.add_entity(pos,'automobiles_coupe:pivot_mesh')
|
||||
passenger_seat:set_attach(self.object,'',{x=4.65,y=0.48,z=9.5},{x=0,y=0,z=0})
|
||||
passenger_seat:set_attach(self.object,'',{x=4.25,y=0.48,z=9.5},{x=0,y=0,z=0})
|
||||
self.passenger_seat = passenger_seat
|
||||
|
||||
local fuel_gauge=minetest.add_entity(pos,'automobiles_coupe:pointer')
|
||||
@ -521,9 +406,6 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
self.lights = lights
|
||||
self.lights:set_properties({is_visible=true})
|
||||
|
||||
--normal or time machine?
|
||||
set_kit(self)
|
||||
|
||||
local r_lights = minetest.add_entity(pos,'automobiles_coupe:r_lights')
|
||||
r_lights:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.r_lights = r_lights
|
||||
@ -603,14 +485,6 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
end
|
||||
end
|
||||
|
||||
--to fix the load on first time
|
||||
if self._coupe_type == 1 then
|
||||
local ent_propertioes = self.normal_kit:get_properties()
|
||||
if ent_propertioes.mesh ~= "automobiles_coupe_time_machine_accessories.b3d" then
|
||||
set_kit(self)
|
||||
end
|
||||
end
|
||||
|
||||
local is_breaking = false
|
||||
if is_attached then
|
||||
local ctrl = player:get_player_control()
|
||||
@ -638,14 +512,14 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
self._last_light_move = 0
|
||||
if self._show_lights == true then
|
||||
--self.lights:set_properties({is_visible=true})
|
||||
self.lights:set_properties({textures={"automobiles_coupe_lights.png", "automobiles_black.png"}, glow=15})
|
||||
self.lights:set_properties({textures={"automobiles_coupe_lights.png"}, glow=15})
|
||||
if is_breaking == false then
|
||||
self.r_lights:set_properties({textures={"automobiles_rear_lights.png"}, glow=10})
|
||||
end
|
||||
automobiles_lib.put_light(self)
|
||||
else
|
||||
--self.lights:set_properties({is_visible=false})
|
||||
self.lights:set_properties({textures={"automobiles_grey.png", "automobiles_black.png"}, glow=0})
|
||||
self.lights:set_properties({textures={"automobiles_grey.png"}, glow=0})
|
||||
if is_breaking == false then
|
||||
self.r_lights:set_properties({textures={"automobiles_rear_lights_off.png"}, glow=0})
|
||||
end
|
||||
@ -713,7 +587,7 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
self.rr_wheel:set_animation_frame_speed(-longit_speed * (12 + angle_factor))
|
||||
|
||||
--whell turn
|
||||
self.object:set_bone_position("drive_wheel", {x=-0, y=0, z=0}, {x=0, y=0, z=-self._steering_angle*2})
|
||||
self.steering:set_attach(self.steering_axis,'',{x=0,y=0,z=0},{x=0,y=0,z=self._steering_angle*2})
|
||||
self.lf_wheel:set_attach(self.front_suspension,'',{x=-coupe.front_wheel_xpos,y=0,z=0},{x=0,y=-self._steering_angle-angle_factor,z=0})
|
||||
self.rf_wheel:set_attach(self.front_suspension,'',{x=coupe.front_wheel_xpos,y=0,z=0},{x=0,y=(-self._steering_angle+angle_factor)+180,z=0})
|
||||
|
||||
@ -728,13 +602,10 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
if math.abs(self._steering_angle) > 15 and self._turn_light_timer >= 1 then
|
||||
self._turn_light_timer = 0
|
||||
--set turn light
|
||||
--minetest.chat_send_all(self._steering_angle)
|
||||
if self._steering_angle < 0 then
|
||||
--minetest.chat_send_all("direita")
|
||||
self.turn_r_light:set_properties({textures={"automobiles_turn_on.png"}, glow=20})
|
||||
end
|
||||
if self._steering_angle > 0 then
|
||||
--minetest.chat_send_all("esquerda")
|
||||
self.turn_l_light:set_properties({textures={"automobiles_turn_on.png"}, glow=20})
|
||||
end
|
||||
end
|
||||
@ -800,7 +671,7 @@ minetest.register_entity("automobiles_coupe:coupe", {
|
||||
self._last_ground_check = self._last_ground_check + dtime
|
||||
if self._last_ground_check > 0.18 then
|
||||
self._last_ground_check = 0
|
||||
automobiles_lib.ground_get_distances(self, 0.372, 2.6)
|
||||
automobiles_lib.ground_get_distances(self, 0.372, 2.3)
|
||||
end
|
||||
local newpitch = self._pitch --velocity.y * math.rad(6)
|
||||
|
||||
|
0
automobiles_coupe/coupe_forms.lua
Normal file → Executable file
0
automobiles_coupe/coupe_forms.lua
Normal file → Executable file
@ -31,13 +31,14 @@ function coupe.destroy(self, puncher)
|
||||
if self.rear_suspension then self.rear_suspension:remove() end
|
||||
if self.lr_wheel then self.lr_wheel:remove() end
|
||||
if self.rr_wheel then self.rr_wheel:remove() end
|
||||
if self.steering then self.steering:remove() end
|
||||
if self.steering_axis then self.steering_axis:remove() end
|
||||
if self.driver_seat then self.driver_seat:remove() end
|
||||
if self.passenger_seat then self.passenger_seat:remove() end
|
||||
if self.fuel_gauge then self.fuel_gauge:remove() end
|
||||
if self.lights then self.lights:remove() end
|
||||
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.turn_l_light then self.turn_l_light:remove() end
|
||||
if self.turn_r_light then self.turn_r_light:remove() end
|
||||
|
||||
|
@ -3,14 +3,14 @@
|
||||
--
|
||||
coupe={}
|
||||
coupe.LONGIT_DRAG_FACTOR = 0.12*0.12
|
||||
coupe.LATER_DRAG_FACTOR = 8.0
|
||||
coupe.LATER_DRAG_FACTOR = 18.0
|
||||
coupe.gravity = automobiles_lib.gravity
|
||||
coupe.max_speed = 30
|
||||
coupe.max_speed = 22
|
||||
coupe.max_acc_factor = 8
|
||||
coupe.max_fuel = 10
|
||||
coupe.trunk_slots = 8
|
||||
|
||||
COUPE_GAUGE_FUEL_POSITION = {x=-4.66,y=6.2,z=17.9}
|
||||
COUPE_GAUGE_FUEL_POSITION = {x=0,y=6.2,z=15.8}
|
||||
|
||||
coupe.front_wheel_xpos = 9.5
|
||||
coupe.rear_wheel_xpos = 9.5
|
||||
|
0
automobiles_coupe/locale/automobiles_coupe.eo.tr
Normal file → Executable file
0
automobiles_coupe/locale/automobiles_coupe.eo.tr
Normal file → Executable file
0
automobiles_coupe/locale/template.txt
Normal file → Executable file
0
automobiles_coupe/locale/template.txt
Normal file → Executable file
Binary file not shown.
BIN
automobiles_coupe/models/automobiles_coupe_drive_wheel.b3d
Executable file
BIN
automobiles_coupe/models/automobiles_coupe_drive_wheel.b3d
Executable file
Binary file not shown.
Binary file not shown.
BIN
automobiles_coupe/models/automobiles_coupe_panel.b3d
Executable file
BIN
automobiles_coupe/models/automobiles_coupe_panel.b3d
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
automobiles_coupe/screenshot.jpg
Executable file
BIN
automobiles_coupe/screenshot.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
0
automobiles_coupe/sounds/coupe_engine.ogg
Normal file → Executable file
0
automobiles_coupe/sounds/coupe_engine.ogg
Normal file → Executable file
Binary file not shown.
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.2 KiB |
10
automobiles_delorean/README.md
Executable file
10
automobiles_delorean/README.md
Executable file
@ -0,0 +1,10 @@
|
||||
## Coupe
|
||||
|
||||
This mod adds a coupe automobile to Minetest.
|
||||
|
||||
## Licenses
|
||||
- Code: see [LICENSE](/LICENSE)
|
||||
- Media: Model adapted from car assets v1 made by https://www.racoon-media.nl; licence CC0
|
||||
|
||||
## Screenshot
|
||||

|
100
automobiles_delorean/control.lua
Executable file
100
automobiles_delorean/control.lua
Executable file
@ -0,0 +1,100 @@
|
||||
--global constants
|
||||
|
||||
function delorean.control(self, dtime, hull_direction, longit_speed, longit_drag, later_drag, accel, max_acc_factor, max_speed, steering_limit, steering_speed)
|
||||
self._last_time_command = self._last_time_command + dtime
|
||||
if self._last_time_command > 1 then self._last_time_command = 1 end
|
||||
|
||||
local player = minetest.get_player_by_name(self.driver_name)
|
||||
local retval_accel = accel;
|
||||
local stop = false
|
||||
|
||||
-- player control
|
||||
if player then
|
||||
local ctrl = player:get_player_control()
|
||||
|
||||
local acc = 0
|
||||
if self._energy > 0 then
|
||||
if longit_speed < max_speed and ctrl.up then
|
||||
--get acceleration factor
|
||||
acc = automobiles_lib.check_road_is_ok(self.object, max_acc_factor)
|
||||
--minetest.chat_send_all('engineacc: '.. engineacc)
|
||||
if acc > 1 and acc < max_acc_factor and longit_speed > 0 then
|
||||
--improper road will reduce speed
|
||||
acc = -1
|
||||
end
|
||||
end
|
||||
|
||||
--reversing
|
||||
if not self.is_flying or self.is_flying == 0 then
|
||||
if ctrl.sneak and longit_speed <= 1.0 and longit_speed > -1.0 then
|
||||
acc = -2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--break
|
||||
if ctrl.down then
|
||||
--[[if math.abs(longit_speed) > 0 then
|
||||
acc = -5 / (longit_speed / 2) -- lets set a brake efficience based on speed
|
||||
end]]--
|
||||
|
||||
--total stop
|
||||
--wheel break
|
||||
if longit_speed > 0 then
|
||||
acc = -5
|
||||
if (longit_speed + acc) < 0 then
|
||||
acc = longit_speed * -1
|
||||
end
|
||||
end
|
||||
|
||||
if not self.is_flying or self.is_flying == 0 then
|
||||
if longit_speed < 0 then
|
||||
acc = 5
|
||||
if (longit_speed + acc) > 0 then
|
||||
acc = longit_speed * -1
|
||||
end
|
||||
end
|
||||
if math.abs(longit_speed) < 0.2 then
|
||||
stop = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if acc then retval_accel=vector.add(accel,vector.multiply(hull_direction,acc)) end
|
||||
|
||||
-- yaw
|
||||
local yaw_cmd = 0
|
||||
if self._yaw_by_mouse == true then
|
||||
local rot_y = math.deg(player:get_look_horizontal())
|
||||
self._steering_angle = automobiles_lib.set_yaw_by_mouse(self, rot_y, steering_limit)
|
||||
else
|
||||
-- steering
|
||||
if ctrl.right then
|
||||
self._steering_angle = math.max(self._steering_angle-steering_speed*dtime,-steering_limit)
|
||||
elseif ctrl.left then
|
||||
self._steering_angle = math.min(self._steering_angle+steering_speed*dtime,steering_limit)
|
||||
else
|
||||
--center steering
|
||||
if longit_speed > 0 then
|
||||
local factor = 1
|
||||
if self._steering_angle > 0 then factor = -1 end
|
||||
local correction = (steering_limit*(longit_speed/75)) * factor
|
||||
local before_correction = self._steering_angle
|
||||
self._steering_angle = self._steering_angle + correction
|
||||
if math.sign(before_correction) ~= math.sign(self._steering_angle) then self._steering_angle = 0 end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local angle_factor = self._steering_angle / 60
|
||||
if angle_factor < 0 then angle_factor = angle_factor * -1 end
|
||||
local deacc_on_curve = longit_speed * angle_factor
|
||||
deacc_on_curve = deacc_on_curve * -1
|
||||
if deacc_on_curve then retval_accel=vector.add(retval_accel,vector.multiply(hull_direction,deacc_on_curve)) end
|
||||
|
||||
end
|
||||
|
||||
return retval_accel, stop
|
||||
end
|
||||
|
||||
|
99
automobiles_delorean/crafts.lua
Normal file
99
automobiles_delorean/crafts.lua
Normal file
@ -0,0 +1,99 @@
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
--
|
||||
-- items
|
||||
--
|
||||
|
||||
-- body
|
||||
minetest.register_craftitem("automobiles_delorean:delorean_body",{
|
||||
description = S("Delorean Body"),
|
||||
inventory_image = "automobiles_delorean_body.png",
|
||||
})
|
||||
|
||||
-- delorean
|
||||
minetest.register_craftitem("automobiles_delorean:delorean", {
|
||||
description = S("Delorean"),
|
||||
inventory_image = "automobiles_delorean.png",
|
||||
liquids_pointable = false,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local pointed_pos = pointed_thing.above
|
||||
--pointed_pos.y=pointed_pos.y+0.2
|
||||
local car = minetest.add_entity(pointed_pos, "automobiles_delorean:delorean")
|
||||
if car and placer then
|
||||
local ent = car:get_luaentity()
|
||||
local owner = placer:get_player_name()
|
||||
if ent then
|
||||
ent.owner = owner
|
||||
ent._delorean_type = 0
|
||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||
car:set_yaw(placer:get_look_horizontal())
|
||||
itemstack:take_item()
|
||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||
automobiles_lib.setText(ent, "Delorean")
|
||||
automobiles_lib.create_inventory(ent, delorean.trunk_slots, owner)
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
-- delorean
|
||||
minetest.register_craftitem("automobiles_delorean:time_machine", {
|
||||
description = S("Time Machine"),
|
||||
inventory_image = "automobiles_delorean.png",
|
||||
liquids_pointable = false,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local pointed_pos = pointed_thing.above
|
||||
--pointed_pos.y=pointed_pos.y+0.2
|
||||
local car = minetest.add_entity(pointed_pos, "automobiles_delorean:delorean")
|
||||
if car and placer then
|
||||
local ent = car:get_luaentity()
|
||||
local owner = placer:get_player_name()
|
||||
if ent then
|
||||
ent.owner = owner
|
||||
ent._delorean_type = 1
|
||||
--minetest.chat_send_all("delorean: " .. ent._delorean_type)
|
||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||
car:set_yaw(placer:get_look_horizontal())
|
||||
itemstack:take_item()
|
||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||
automobiles_lib.setText(ent, "Delorean")
|
||||
automobiles_lib.create_inventory(ent, delorean.trunk_slots, owner)
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- crafting
|
||||
--
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.register_craft({
|
||||
output = "automobiles_delorean:delorean",
|
||||
recipe = {
|
||||
{"automobiles_lib:wheel", "automobiles_lib:engine", "automobiles_lib:wheel"},
|
||||
{"automobiles_lib:wheel","automobiles_delorean:delorean_body", "automobiles_lib:wheel"},
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "automobiles_delorean:delorean_body",
|
||||
recipe = {
|
||||
{"default:glass" ,"default:glass","default:steelblock"},
|
||||
{"default:steelblock","","default:steelblock"},
|
||||
{"default:steelblock","default:steelblock", "default:steelblock"},
|
||||
}
|
||||
})
|
||||
end
|
947
automobiles_delorean/entities.lua
Executable file
947
automobiles_delorean/entities.lua
Executable file
@ -0,0 +1,947 @@
|
||||
--
|
||||
-- entity
|
||||
--
|
||||
|
||||
minetest.register_entity('automobiles_delorean:wheel',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_delorean_wheel.b3d",
|
||||
backface_culling = false,
|
||||
textures = {"automobiles_black.png", "automobiles_metal.png", "automobiles_delorean_wheel.png"},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_delorean:normal_kit',{
|
||||
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_normal_kit.b3d",
|
||||
textures = {"automobiles_black.png","automobiles_delorean_glasses.png"},
|
||||
},
|
||||
|
||||
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:time_machine_kit',{
|
||||
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_accessories.b3d",
|
||||
textures = {
|
||||
"automobiles_metal.png", --ok
|
||||
"automobiles_black.png", --ok
|
||||
"automobiles_dark_grey.png", --exausts
|
||||
"automobiles_black.png", --exausts
|
||||
"automobiles_metal.png", --energy base collector
|
||||
"automobiles_painting.png^[multiply:#0063b0", --capacitors
|
||||
"automobiles_black.png", --arc
|
||||
"automobiles_painting.png^[multiply:#07B6BC", --capacitors
|
||||
"automobiles_black.png", --base mr fusion
|
||||
"automobiles_painting.png", --mr fusion
|
||||
"automobiles_metal.png", --ok
|
||||
"automobiles_painting.png", --ok
|
||||
"automobiles_black.png", --ok
|
||||
"automobiles_metal.png", --lateral tubes
|
||||
"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"},
|
||||
},
|
||||
|
||||
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 = {
|
||||
physical = true,
|
||||
collide_with_objects=true,
|
||||
collisionbox = {-0.5, 0, -0.5, 0.5, 1, 0.5},
|
||||
pointable=false,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_pivot_mesh.b3d",
|
||||
textures = {"automobiles_black.png",},
|
||||
},
|
||||
|
||||
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:rear_suspension',{
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
collide_with_objects=true,
|
||||
pointable=false,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_pivot_mesh.b3d",
|
||||
textures = {"automobiles_black.png",},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_delorean:f_lights',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
glow = 0,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_delorean_f_lights.b3d",
|
||||
textures = {"automobiles_grey.png", "automobiles_black.png"},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_delorean:r_lights',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
glow = 0,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_delorean_rear_pos_lights.b3d",
|
||||
textures = {"automobiles_rear_lights_off.png"},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_delorean:reverse_lights',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
glow = 0,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_delorean_reverse_lights.b3d",
|
||||
textures = {"automobiles_grey.png",},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_delorean:turn_left_light',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
glow = 0,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_delorean_turn_l_light.b3d",
|
||||
textures = {"automobiles_turn.png",},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_delorean:turn_right_light',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
glow = 0,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_delorean_turn_r_light.b3d",
|
||||
textures = {"automobiles_turn.png",},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_delorean:pivot_mesh',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_pivot_mesh.b3d",
|
||||
textures = {"automobiles_black.png",},
|
||||
},
|
||||
|
||||
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,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity('automobiles_delorean:pointer',{
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collide_with_objects=false,
|
||||
pointable=false,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_pointer.b3d",
|
||||
visual_size = {x = 0.5, y = 0.5, z = 0.5},
|
||||
textures = {"automobiles_white.png"},
|
||||
},
|
||||
|
||||
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,
|
||||
})
|
||||
|
||||
minetest.register_entity("automobiles_delorean:delorean", {
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
collide_with_objects = true,
|
||||
collisionbox = {-0.1, -0.2, -0.1, 0.1, 1, 0.1},
|
||||
selectionbox = {-1.5, 0.0, -1.5, 1.5, 2, 1.5},
|
||||
stepheight = 0.65,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_delorean_body.b3d",
|
||||
--use_texture_alpha = true,
|
||||
--backface_culling = false,
|
||||
textures = {
|
||||
"automobiles_dark_grey.png", --bancos
|
||||
"automobiles_painting.png", --pintura portas
|
||||
"automobiles_black.png", --retrovisores
|
||||
"automobiles_dark_grey.png", --forro da porta
|
||||
"automobiles_delorean_glasses.png", --vidros das portas
|
||||
"automobiles_metal.png", --espelhos
|
||||
"automobiles_black.png", --volante
|
||||
"automobiles_painting2.png", --face
|
||||
"automobiles_black.png", --moldura parabrisa
|
||||
"automobiles_delorean_glasses.png", --parabrisa
|
||||
"automobiles_black.png", --grade_motor
|
||||
"automobiles_dark_grey.png", --revestimento interno
|
||||
"automobiles_delorean_fuel.png", --combustivel
|
||||
"automobiles_painting.png", --pintura
|
||||
"automobiles_black.png", --frisos
|
||||
"automobiles_black.png", --paralamas
|
||||
"automobiles_black.png", --assoalho
|
||||
"automobiles_painting2.png", --traseira
|
||||
"automobiles_black.png", --traseira placa
|
||||
"automobiles_black.png", --ventilação vidro traseiro
|
||||
},
|
||||
},
|
||||
textures = {},
|
||||
driver_name = nil,
|
||||
sound_handle = nil,
|
||||
owner = "",
|
||||
static_save = true,
|
||||
infotext = "A very nice delorean!",
|
||||
hp = 50,
|
||||
buoyancy = 2,
|
||||
physics = automobiles_lib.physics,
|
||||
lastvelocity = vector.new(),
|
||||
time_total = 0,
|
||||
_passenger = nil,
|
||||
_color = "#9f9f9f",
|
||||
_steering_angle = 0,
|
||||
_engine_running = false,
|
||||
_last_checkpoint = "",
|
||||
_total_laps = -1,
|
||||
_race_id = "",
|
||||
_energy = 1,
|
||||
_last_time_collision_snd = 0,
|
||||
_last_time_drift_snd = 0,
|
||||
_last_time_command = 0,
|
||||
_roll = math.rad(0),
|
||||
_pitch = 0,
|
||||
_longit_speed = 0,
|
||||
_show_rag = true,
|
||||
_show_lights = false,
|
||||
_light_old_pos = nil,
|
||||
_last_ground_check = 0,
|
||||
_last_light_move = 0,
|
||||
_last_engine_sound_update = 0,
|
||||
_turn_light_timer = 0,
|
||||
_inv = nil,
|
||||
_inv_id = "",
|
||||
_change_color = automobiles_lib.paint,
|
||||
_intensity = 4,
|
||||
_delorean_type = 0,
|
||||
_car_gravity = -automobiles_lib.gravity,
|
||||
|
||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||
return minetest.serialize({
|
||||
stored_owner = self.owner,
|
||||
stored_hp = self.hp,
|
||||
stored_color = self._color,
|
||||
stored_steering = self._steering_angle,
|
||||
stored_energy = self._energy,
|
||||
--race data
|
||||
stored_last_checkpoint = self._last_checkpoint,
|
||||
stored_total_laps = self._total_laps,
|
||||
stored_race_id = self._race_id,
|
||||
stored_rag = self._show_rag,
|
||||
stored_pitch = self._pitch,
|
||||
stored_light_old_pos = self._light_old_pos,
|
||||
stored_inv_id = self._inv_id,
|
||||
stored_delorean_type = self._delorean_type,
|
||||
stored_car_gravity = self._car_gravity,
|
||||
})
|
||||
end,
|
||||
|
||||
on_deactivate = function(self)
|
||||
automobiles_lib.save_inventory(self)
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if staticdata ~= "" and staticdata ~= nil then
|
||||
local data = minetest.deserialize(staticdata) or {}
|
||||
self.owner = data.stored_owner
|
||||
self.hp = data.stored_hp
|
||||
self._color = data.stored_color
|
||||
self._steering_angle = data.stored_steering
|
||||
self._energy = data.stored_energy
|
||||
--minetest.debug("loaded: ", self.energy)
|
||||
--race data
|
||||
self._last_checkpoint = data.stored_last_checkpoint
|
||||
self._total_laps = data.stored_total_laps
|
||||
self._race_id = data.stored_race_id
|
||||
self._show_rag = data.stored_rag
|
||||
self._pitch = data.stored_pitch
|
||||
self._light_old_pos = data.stored_light_old_pos
|
||||
self._inv_id = data.stored_inv_id
|
||||
|
||||
self._delorean_type = data.stored_delorean_type
|
||||
self._car_gravity = data.stored_car_gravity or -automobiles_lib.gravity
|
||||
|
||||
automobiles_lib.setText(self, "Delorean")
|
||||
end
|
||||
|
||||
self.object:set_animation({x = 1, y = 8}, 0, 0, true)
|
||||
|
||||
automobiles_lib.paint(self, self._color)
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
local front_suspension=minetest.add_entity(self.object:get_pos(),'automobiles_delorean:front_suspension')
|
||||
front_suspension:set_attach(self.object,'',{x=0,y=1.5,z=27.7057},{x=0,y=0,z=0})
|
||||
self.front_suspension = front_suspension
|
||||
|
||||
local lf_wheel=minetest.add_entity(pos,'automobiles_delorean:wheel')
|
||||
lf_wheel:set_attach(self.front_suspension,'',{x=-delorean.front_wheel_xpos,y=0,z=0},{x=0,y=0,z=0})
|
||||
-- set the animation once and later only change the speed
|
||||
lf_wheel:set_animation({x = 1, y = 49}, 0, 0, true)
|
||||
self.lf_wheel = lf_wheel
|
||||
|
||||
local rf_wheel=minetest.add_entity(pos,'automobiles_delorean:wheel')
|
||||
rf_wheel:set_attach(self.front_suspension,'',{x=delorean.front_wheel_xpos,y=0,z=0},{x=0,y=180,z=0})
|
||||
-- set the animation once and later only change the speed
|
||||
rf_wheel:set_animation({x = 1, y = 49}, 0, 0, true)
|
||||
self.rf_wheel = rf_wheel
|
||||
|
||||
local rear_suspension=minetest.add_entity(self.object:get_pos(),'automobiles_delorean:rear_suspension')
|
||||
rear_suspension:set_attach(self.object,'',{x=0,y=1.5,z=0},{x=0,y=0,z=0})
|
||||
self.rear_suspension = rear_suspension
|
||||
|
||||
local lr_wheel=minetest.add_entity(pos,'automobiles_delorean:wheel')
|
||||
lr_wheel:set_attach(self.rear_suspension,'',{x=-delorean.rear_wheel_xpos,y=0,z=0},{x=0,y=0,z=0})
|
||||
-- set the animation once and later only change the speed
|
||||
lr_wheel:set_animation({x = 1, y = 49}, 0, 0, true)
|
||||
self.lr_wheel = lr_wheel
|
||||
|
||||
local rr_wheel=minetest.add_entity(pos,'automobiles_delorean:wheel')
|
||||
rr_wheel:set_attach(self.rear_suspension,'',{x=delorean.rear_wheel_xpos,y=0,z=0},{x=0,y=180,z=0})
|
||||
-- set the animation once and later only change the speed
|
||||
rr_wheel:set_animation({x = 1, y = 49}, 0, 0, true)
|
||||
self.rr_wheel = rr_wheel
|
||||
|
||||
self.object:set_bone_position("drive_adjust", {x=-4.66, y=6.31, z=15.69}, {x=15, y=0, z=0})
|
||||
|
||||
local driver_seat=minetest.add_entity(pos,'automobiles_delorean:pivot_mesh')
|
||||
driver_seat:set_attach(self.object,'',{x=-4.65,y=0.48,z=9.5},{x=0,y=0,z=0})
|
||||
self.driver_seat = driver_seat
|
||||
|
||||
local passenger_seat=minetest.add_entity(pos,'automobiles_delorean:pivot_mesh')
|
||||
passenger_seat:set_attach(self.object,'',{x=4.65,y=0.48,z=9.5},{x=0,y=0,z=0})
|
||||
self.passenger_seat = passenger_seat
|
||||
|
||||
local fuel_gauge=minetest.add_entity(pos,'automobiles_delorean:pointer')
|
||||
fuel_gauge:set_attach(self.object,'',DELOREAN_GAUGE_FUEL_POSITION,{x=0,y=0,z=0})
|
||||
self.fuel_gauge = fuel_gauge
|
||||
|
||||
local lights = minetest.add_entity(pos,'automobiles_delorean:f_lights')
|
||||
lights:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.lights = lights
|
||||
self.lights:set_properties({is_visible=true})
|
||||
|
||||
--normal or time machine?
|
||||
delorean.set_kit(self)
|
||||
|
||||
local r_lights = minetest.add_entity(pos,'automobiles_delorean:r_lights')
|
||||
r_lights:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.r_lights = r_lights
|
||||
self.r_lights:set_properties({is_visible=true})
|
||||
|
||||
local reverse_lights = minetest.add_entity(pos,'automobiles_delorean:reverse_lights')
|
||||
reverse_lights:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.reverse_lights = reverse_lights
|
||||
self.reverse_lights:set_properties({is_visible=true})
|
||||
|
||||
local turn_l_light = minetest.add_entity(pos,'automobiles_delorean:turn_left_light')
|
||||
turn_l_light:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.turn_l_light = turn_l_light
|
||||
self.turn_l_light:set_properties({is_visible=true})
|
||||
|
||||
local turn_r_light = minetest.add_entity(pos,'automobiles_delorean:turn_right_light')
|
||||
turn_r_light:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.turn_r_light = turn_r_light
|
||||
self.turn_r_light:set_properties({is_visible=true})
|
||||
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
|
||||
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 not inv then
|
||||
automobiles_lib.create_inventory(self, delorean.trunk_slots)
|
||||
else
|
||||
self.inv = inv
|
||||
end
|
||||
|
||||
|
||||
automobiles_lib.actfunc(self, staticdata, dtime_s)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
automobiles_lib.stepfunc(self, dtime)
|
||||
--[[sound play control]]--
|
||||
self._last_time_collision_snd = self._last_time_collision_snd + dtime
|
||||
if self._last_time_collision_snd > 1 then self._last_time_collision_snd = 1 end
|
||||
self._last_time_drift_snd = self._last_time_drift_snd + dtime
|
||||
if self._last_time_drift_snd > 1 then self._last_time_drift_snd = 1 end
|
||||
--[[end sound control]]--
|
||||
|
||||
local rotation = self.object:get_rotation()
|
||||
local yaw = rotation.y
|
||||
local newyaw=yaw
|
||||
local pitch = rotation.x
|
||||
|
||||
local hull_direction = minetest.yaw_to_dir(yaw)
|
||||
local nhdir = {x=hull_direction.z,y=0,z=-hull_direction.x} -- lateral unit vector
|
||||
local velocity = self.object:get_velocity()
|
||||
|
||||
local longit_speed = automobiles_lib.dot(velocity,hull_direction)
|
||||
local fuel_weight_factor = (5 - self._energy)/5000
|
||||
local longit_drag = vector.multiply(hull_direction,(longit_speed*longit_speed) *
|
||||
(delorean.LONGIT_DRAG_FACTOR - fuel_weight_factor) * -1 * automobiles_lib.sign(longit_speed))
|
||||
|
||||
local later_speed = automobiles_lib.dot(velocity,nhdir)
|
||||
local later_drag = vector.multiply(nhdir,later_speed*
|
||||
later_speed*delorean.LATER_DRAG_FACTOR*-1*automobiles_lib.sign(later_speed))
|
||||
|
||||
local accel = vector.add(longit_drag,later_drag)
|
||||
local stop = nil
|
||||
|
||||
local player = nil
|
||||
local is_attached = false
|
||||
if self.driver_name then
|
||||
player = minetest.get_player_by_name(self.driver_name)
|
||||
|
||||
if player then
|
||||
local player_attach = player:get_attach()
|
||||
if player_attach then
|
||||
if self.driver_seat then
|
||||
if player_attach == self.driver_seat then is_attached = true end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--to fix the load on first time
|
||||
self.is_flying = 0
|
||||
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
|
||||
else
|
||||
self._car_gravity = -automobiles_lib.gravity
|
||||
end
|
||||
delorean.gravity_auto_correction(self, dtime)
|
||||
end
|
||||
|
||||
local is_breaking = false
|
||||
if is_attached then
|
||||
local ctrl = player:get_player_control()
|
||||
if ctrl.aux1 then
|
||||
--sets the engine running - but sets a delay also, cause keypress
|
||||
if self._last_time_command > 0.8 then
|
||||
self._last_time_command = 0
|
||||
minetest.sound_play({name = "automobiles_horn"},
|
||||
{object = self.object, gain = 0.6, pitch = 1.0, max_hear_distance = 32, loop = false,})
|
||||
end
|
||||
end
|
||||
if ctrl.down then
|
||||
is_breaking = true
|
||||
self.r_lights:set_properties({textures={"automobiles_rear_lights_full.png"}, glow=15})
|
||||
end
|
||||
if ctrl.sneak then
|
||||
self.reverse_lights:set_properties({textures={"automobiles_white.png"}, glow=15})
|
||||
else
|
||||
self.reverse_lights:set_properties({textures={"automobiles_grey.png"}, glow=0})
|
||||
end
|
||||
end
|
||||
|
||||
self._last_light_move = self._last_light_move + dtime
|
||||
if self._last_light_move > 0.15 then
|
||||
self._last_light_move = 0
|
||||
if self._show_lights == true then
|
||||
--self.lights:set_properties({is_visible=true})
|
||||
self.lights:set_properties({textures={"automobiles_delorean_lights.png", "automobiles_black.png"}, glow=15})
|
||||
if is_breaking == false then
|
||||
self.r_lights:set_properties({textures={"automobiles_rear_lights.png"}, glow=10})
|
||||
end
|
||||