more mods
No files matched your search
@@ -0,0 +1,10 @@
|
||||
## Delorean
|
||||
|
||||
This mod adds a delorean automobile to Minetest.
|
||||
|
||||
## Licenses
|
||||
- Code: see [LICENSE](/LICENSE)
|
||||
- Media: Model made by myself, licence CC0
|
||||
|
||||
## Screenshot
|
||||

|
||||
@@ -0,0 +1,102 @@
|
||||
--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 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 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
|
||||
else
|
||||
acc = -5
|
||||
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
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
local S = delorean.S
|
||||
|
||||
--
|
||||
-- items
|
||||
--
|
||||
|
||||
-- body
|
||||
minetest.register_craftitem("automobiles_delorean:delorean_body",{
|
||||
description = S("Delorean Body"),
|
||||
inventory_image = "automobiles_delorean_body.png",
|
||||
})
|
||||
|
||||
-- delorean
|
||||
minetest.register_tool("automobiles_delorean:delorean", {
|
||||
description = S("Delorean"),
|
||||
inventory_image = "automobiles_delorean.png",
|
||||
liquids_pointable = false,
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local stack_meta = itemstack:get_meta()
|
||||
local staticdata = stack_meta:get_string("staticdata")
|
||||
|
||||
local pointed_pos = pointed_thing.above
|
||||
--pointed_pos.y=pointed_pos.y+0.2
|
||||
local car = minetest.add_entity(pointed_pos, "automobiles_delorean:delorean", staticdata)
|
||||
if car and placer then
|
||||
local ent = car:get_luaentity()
|
||||
local owner = placer:get_player_name()
|
||||
if ent then
|
||||
ent.owner = owner
|
||||
ent.hp = 50 --reset hp
|
||||
ent._car_type = ent._car_type or 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, S("Delorean"))
|
||||
automobiles_lib.create_inventory(ent, ent._trunk_slots, owner)
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
-- delorean
|
||||
minetest.register_tool("automobiles_delorean:time_machine", {
|
||||
description = S("Time Machine"),
|
||||
inventory_image = "automobiles_delorean.png",
|
||||
liquids_pointable = false,
|
||||
stack_max = 1,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local stack_meta = itemstack:get_meta()
|
||||
local staticdata = stack_meta:get_string("staticdata")
|
||||
|
||||
local pointed_pos = pointed_thing.above
|
||||
--pointed_pos.y=pointed_pos.y+0.2
|
||||
local car = minetest.add_entity(pointed_pos, "automobiles_delorean:delorean", staticdata)
|
||||
if car and placer then
|
||||
local ent = car:get_luaentity()
|
||||
local owner = placer:get_player_name()
|
||||
if ent then
|
||||
ent.owner = owner
|
||||
ent.hp = 50 --reset hp
|
||||
ent._car_type = ent._car_type or 1
|
||||
--minetest.chat_send_all("delorean: " .. ent._car_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, ent._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
|
||||
@@ -0,0 +1,460 @@
|
||||
local S = delorean.S
|
||||
|
||||
function delorean.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._car_type == 0 or self._car_type == nil then
|
||||
normal_kit = minetest.add_entity(pos,'automobiles_delorean: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._car_type == 1 then
|
||||
--time machine
|
||||
normal_kit = minetest.add_entity(pos,'automobiles_delorean: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})
|
||||
|
||||
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
|
||||
|
||||
--
|
||||
-- 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", --base circuit switch
|
||||
"automobiles_red.png", --red button
|
||||
"automobiles_dark_grey.png", --ok
|
||||
"automobiles_delorean_brass.png", --ok
|
||||
"automobiles_black.png", --electric switch
|
||||
"automobiles_dark_grey.png", --base
|
||||
"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: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 = {
|
||||
physical = true,
|
||||
collide_with_objects=true,
|
||||
collisionbox = {-0.5, 0, -0.5, 0.5, 1, 0.5},
|
||||
pointable=false,
|
||||
visual = "sprite",
|
||||
textures = {"automobiles_alpha.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 = "sprite",
|
||||
textures = {"automobiles_alpha.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: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 + automobiles_lib.extra_stepheight,
|
||||
visual = "mesh",
|
||||
mesh = "automobiles_delorean_body.b3d",
|
||||
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 = S("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,
|
||||
_car_type = nil,
|
||||
_car_gravity = -automobiles_lib.gravity,
|
||||
_is_flying = 0,
|
||||
_trunk_slots = 8,
|
||||
_engine_sound = "delorean_engine",
|
||||
_max_fuel = 10,
|
||||
_formspec_function = delorean.driver_formspec,
|
||||
|
||||
_vehicle_name = S("Delorean"),
|
||||
_drive_wheel_pos = {x=-4.66, y=6.31, z=15.69},
|
||||
_drive_wheel_angle = 15,
|
||||
_seat_pos = {{x=-4.65,y=0.48,z=9.5},{x=4.65,y=0.48,z=9.5}},
|
||||
|
||||
_front_suspension_ent = 'automobiles_delorean:front_suspension',
|
||||
_front_suspension_pos = {x=0,y=1.5,z=27.7057},
|
||||
_front_wheel_ent = 'automobiles_delorean:wheel',
|
||||
_front_wheel_xpos = 9.5,
|
||||
_front_wheel_frames = {x = 1, y = 49},
|
||||
_rear_suspension_ent = 'automobiles_delorean:rear_suspension',
|
||||
_rear_suspension_pos = {x=0,y=1.5,z=0},
|
||||
_rear_wheel_ent = 'automobiles_delorean:wheel',
|
||||
_rear_wheel_xpos = 9.5,
|
||||
_rear_wheel_frames = {x = 1, y = 49},
|
||||
|
||||
_fuel_gauge_pos = {x=-4.66,y=6.2,z=17.9},
|
||||
_front_lights = 'automobiles_delorean:f_lights',
|
||||
_rear_lights = 'automobiles_delorean:r_lights',
|
||||
_reverse_lights = 'automobiles_delorean:reverse_lights',
|
||||
_turn_left_lights = 'automobiles_delorean:turn_left_light',
|
||||
_turn_right_lights = 'automobiles_delorean:turn_right_light',
|
||||
_textures_turn_lights_off = {"automobiles_turn.png", },
|
||||
_textures_turn_lights_on = { "automobiles_turn_on.png", },
|
||||
_extra_items_function = delorean.set_kit, --uses _car_type do change "skin"
|
||||
|
||||
_setmode = delorean.set_mode,
|
||||
_control_function = delorean.control,
|
||||
|
||||
_LONGIT_DRAG_FACTOR = 0.12*0.12,
|
||||
_LATER_DRAG_FACTOR = 8.0,
|
||||
_max_acc_factor = 8.0,
|
||||
_max_speed = 30,
|
||||
_min_later_speed = 4.5,
|
||||
_consumption_divisor = 40000,
|
||||
|
||||
_wheel_compensation = 0.8,
|
||||
|
||||
get_staticdata = automobiles_lib.get_staticdata,
|
||||
|
||||
on_deactivate = function(self)
|
||||
automobiles_lib.save_inventory(self)
|
||||
end,
|
||||
|
||||
on_activate = automobiles_lib.on_activate,
|
||||
|
||||
on_step = automobiles_lib.on_step,
|
||||
|
||||
on_punch = automobiles_lib.on_punch,
|
||||
on_rightclick = automobiles_lib.on_rightclick,
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
function delorean.gravity_auto_correction(self, dtime)
|
||||
local factor = 1
|
||||
--minetest.chat_send_player(self.driver_name, "antes: " .. self._car_gravity)
|
||||
if self._car_gravity > 0 then factor = -1 end
|
||||
local time_correction = (dtime/automobiles_lib.ideal_step)
|
||||
local intensity = 1
|
||||
local correction = (intensity*factor) * time_correction
|
||||
if math.abs(correction) > 1 then correction = 1 * math.sign(correction) end
|
||||
--minetest.chat_send_player(self.driver_name, correction)
|
||||
local before_correction = self._car_gravity
|
||||
local new_car_gravity = self._car_gravity + correction
|
||||
if math.sign(before_correction) ~= math.sign(new_car_gravity) then
|
||||
self._car_gravity = 0
|
||||
else
|
||||
self._car_gravity = new_car_gravity
|
||||
end
|
||||
|
||||
--now desacelerate
|
||||
if self._car_gravity == 0 then
|
||||
local curr_vel = self.object:get_velocity()
|
||||
if curr_vel.y < 0 then
|
||||
self._car_gravity = 0.5
|
||||
else
|
||||
self._car_gravity = -0.5
|
||||
end
|
||||
end
|
||||
|
||||
--minetest.chat_send_player(self.driver_name, "depois: " .. self._car_gravity)
|
||||
end
|
||||
|
||||
function delorean.control_flight(self, player)
|
||||
if self._is_flying == 1 then
|
||||
local ctrl = player:get_player_control()
|
||||
local max = 6
|
||||
local min = -6
|
||||
local curr_vel = self.object:get_velocity()
|
||||
if ctrl.jump then
|
||||
if self._car_gravity < max and curr_vel.y < 2.5 then
|
||||
self._car_gravity = self._car_gravity + 1
|
||||
end
|
||||
elseif ctrl.sneak then
|
||||
if self._car_gravity > min and curr_vel.y > -2.5 then
|
||||
self._car_gravity = self._car_gravity - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function delorean.set_wheels_mode(self, angle_factor)
|
||||
if not self._is_flying or self._is_flying == 0 then
|
||||
--whell turn
|
||||
--[[self.lf_wheel:set_attach(self.front_suspension,'',{x=-self._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=self._front_wheel_xpos,y=0,z=0},{x=0,y=(-self._steering_angle+angle_factor)+180,z=0})
|
||||
self.lr_wheel:set_attach(self.rear_suspension,'',{x=-self._rear_wheel_xpos,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.rr_wheel:set_attach(self.rear_suspension,'',{x=self._rear_wheel_xpos,y=0,z=0},{x=0,y=180,z=0})]]--
|
||||
else
|
||||
local extra_space = 0.5
|
||||
self.lf_wheel:set_attach(self.front_suspension,'',{x=-self._front_wheel_xpos-extra_space,y=0,z=0},{x=0,y=0,z=90})
|
||||
self.rf_wheel:set_attach(self.front_suspension,'',{x=self._front_wheel_xpos+extra_space,y=0,z=0},{x=0,y=180,z=-90})
|
||||
self.lr_wheel:set_attach(self.rear_suspension,'',{x=-self._rear_wheel_xpos-extra_space,y=0,z=0},{x=0,y=0,z=90})
|
||||
self.rr_wheel:set_attach(self.rear_suspension,'',{x=self._rear_wheel_xpos+extra_space,y=0,z=0},{x=0,y=180,z=-90})
|
||||
end
|
||||
end
|
||||
|
||||
function delorean.turn_flight_mode(self)
|
||||
if self._is_flying == 1 then
|
||||
--initial lift
|
||||
self._car_gravity = 10
|
||||
local curr_pos = self.object:get_pos()
|
||||
curr_pos.y = curr_pos.y + 1.5
|
||||
self.object:move_to(curr_pos)
|
||||
self._start_flight_semaphore = 1 --semaphore to avoid the grouund detection on first loop
|
||||
end
|
||||
end
|
||||
|
||||
function delorean.set_mode(self, is_attached, curr_pos, velocity, player, dtime)
|
||||
if self._car_type == 1 then
|
||||
local ent_properties = self.normal_kit:get_properties()
|
||||
if ent_properties then
|
||||
if ent_properties.mesh ~= "automobiles_delorean_time_machine_accessories.b3d" then
|
||||
delorean.set_kit(self)
|
||||
end
|
||||
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
|
||||
if not self._start_flight_semaphore then --check if the flight started now
|
||||
self._is_flying = 0
|
||||
else
|
||||
self._start_flight_semaphore = nil --set the deactivation to work normally now
|
||||
end
|
||||
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
|
||||
delorean.set_wheels_mode(self, 0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
local S = delorean.S
|
||||
--------------
|
||||
-- Manual --
|
||||
--------------
|
||||
|
||||
function delorean.getCarFromPlayer(player)
|
||||
local seat = player:get_attach()
|
||||
if seat then
|
||||
local car = seat:get_attach()
|
||||
return car
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function delorean.driver_formspec(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local vehicle_obj = delorean.getCarFromPlayer(player)
|
||||
if vehicle_obj == nil then
|
||||
return
|
||||
end
|
||||
local ent = vehicle_obj:get_luaentity()
|
||||
|
||||
local yaw = "false"
|
||||
local one_hand = "false"
|
||||
if ent._yaw_by_mouse then yaw = "true" end
|
||||
if ent._one_hand then one_hand = "true" end
|
||||
|
||||
local flight = "false"
|
||||
if ent._is_flying == 1 then flight = "true" end
|
||||
|
||||
local basic_form = table.concat({
|
||||
"formspec_version[3]",
|
||||
"size[6,7]",
|
||||
}, "")
|
||||
|
||||
basic_form = basic_form.."button[1,1.0;4,1;go_out;" .. S("Go Offboard") .. "]"
|
||||
basic_form = basic_form.."button[1,2.5;4,1;lights;" .. S("Lights") .. "]"
|
||||
if ent._car_type == 1 then basic_form = basic_form.."checkbox[1,4.0;flight;" .. S("Flight Mode") .. ";"..flight.."]" end
|
||||
basic_form = basic_form.."checkbox[1,5.5;yaw;" .. S("Direction by mouse") .. ";"..yaw.."]"
|
||||
--if ent._car_type ~= 1 then basic_form = basic_form.."checkbox[1,6.2;one_hand;" .. S("One Hand Driving\n(open menu using AUX)") .. ";"..one_hand.."]" end
|
||||
|
||||
minetest.show_formspec(name, "delorean:driver_main", basic_form)
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "delorean:driver_main" then
|
||||
local name = player:get_player_name()
|
||||
local car_obj = delorean.getCarFromPlayer(player)
|
||||
if car_obj then
|
||||
local ent = car_obj:get_luaentity()
|
||||
if ent then
|
||||
if fields.go_out then
|
||||
if ent._passenger then --any pax?
|
||||
local pax_obj = minetest.get_player_by_name(ent._passenger)
|
||||
automobiles_lib.dettach_pax(ent, pax_obj)
|
||||
end
|
||||
ent._is_flying = 0
|
||||
automobiles_lib.dettach_driver(ent, player)
|
||||
end
|
||||
if fields.lights then
|
||||
if ent._show_lights == true then
|
||||
ent._show_lights = false
|
||||
else
|
||||
ent._show_lights = true
|
||||
end
|
||||
end
|
||||
if fields.yaw then
|
||||
if ent._yaw_by_mouse == true then
|
||||
ent._yaw_by_mouse = false
|
||||
else
|
||||
ent._yaw_by_mouse = true
|
||||
end
|
||||
end
|
||||
if fields.flight then
|
||||
if ent._is_flying == 1 then
|
||||
ent._is_flying = 0
|
||||
else
|
||||
ent._is_flying = 1
|
||||
end
|
||||
delorean.turn_flight_mode(ent)
|
||||
end
|
||||
if fields.one_hand then
|
||||
if ent._one_hand == true then
|
||||
ent._one_hand = false
|
||||
else
|
||||
ent._one_hand = true
|
||||
core.chat_send_player(name,core.colorize('#00ff00', S(" >>> Use AUX or key \"E\" to open the menu")))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.close_formspec(name, "delorean:driver_main")
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,29 @@
|
||||
--
|
||||
-- constants
|
||||
--
|
||||
delorean={}
|
||||
delorean.gravity = automobiles_lib.gravity
|
||||
|
||||
delorean.S = nil
|
||||
|
||||
if(minetest.get_translator ~= nil) then
|
||||
delorean.S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
else
|
||||
delorean.S = function ( s ) return s end
|
||||
|
||||
end
|
||||
|
||||
local S = delorean.S
|
||||
|
||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "custom_physics.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 .. "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 .. "flight.lua")
|
||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "entities.lua")
|
||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "crafts.lua")
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# textdomain: automobiles_delorean
|
||||
### coupe_crafts.lua ###
|
||||
Delorean Body=Delorean Karrosserie
|
||||
Time Machine=Zeitmaschine
|
||||
Delorean=Delorean
|
||||
A very nice delorean!=Ein sehr schöner Delorean!
|
||||
Go Offboard=Aussteigen
|
||||
Lights=Lichter
|
||||
Flight Mode=Flugmodus
|
||||
Direction by mouse=Lenke mit Maus
|
||||
@@ -0,0 +1,10 @@
|
||||
# textdomain: automobiles_delorean
|
||||
### crafts.lua ###
|
||||
Delorean Body=Korpo de Delorean
|
||||
Time Machine=
|
||||
Delorean=Delorean
|
||||
A very nice delorean!=
|
||||
Go Offboard=
|
||||
Lights=
|
||||
Flight Mode=
|
||||
Direction by mouse=
|
||||
@@ -0,0 +1,10 @@
|
||||
# textdomain: automobiles_delorean
|
||||
### coupe_crafts.lua ###
|
||||
Delorean Body=
|
||||
Time Machine=
|
||||
Delorean=
|
||||
A very nice delorean!=
|
||||
Go Offboard=
|
||||
Lights=
|
||||
Flight Mode=
|
||||
Direction by mouse=
|
||||
@@ -0,0 +1,5 @@
|
||||
name=automobiles_delorean
|
||||
title=Delorean
|
||||
description=A Delorean
|
||||
author=apercy
|
||||
depends=automobiles_lib
|
||||
|
After Width: | Height: | Size: 609 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 22 KiB |