Complete multiple passenger support (#14)
This commit is contained in:
parent
dbd0d395c6
commit
6b3141fd69
@ -1,5 +1,3 @@
|
|||||||
vehicle_mash = { }
|
|
||||||
|
|
||||||
function vehicle_mash.register_vehicle(name, def)
|
function vehicle_mash.register_vehicle(name, def)
|
||||||
minetest.register_entity(name, {
|
minetest.register_entity(name, {
|
||||||
terrain_type = def.terrain_type,
|
terrain_type = def.terrain_type,
|
||||||
@ -13,17 +11,7 @@ function vehicle_mash.register_vehicle(name, def)
|
|||||||
driver_detach_pos_offset = def.driver_detach_pos_offset,
|
driver_detach_pos_offset = def.driver_detach_pos_offset,
|
||||||
number_of_passengers = def.number_of_passengers,
|
number_of_passengers = def.number_of_passengers,
|
||||||
|
|
||||||
passenger_attach_at = def.passenger_attach_at,
|
passengers = def.passengers,
|
||||||
passenger_eye_offset = def.passenger_eye_offset,
|
|
||||||
passenger_detach_pos_offset = def.passenger_detach_pos_offset,
|
|
||||||
|
|
||||||
passenger2_attach_at = def.passenger2_attach_at,
|
|
||||||
passenger2_eye_offset = def.passenger2_eye_offset,
|
|
||||||
passenger2_detach_pos_offset = def.passenger2_detach_pos_offset,
|
|
||||||
|
|
||||||
passenger3_attach_at = def.passenger3_attach_at,
|
|
||||||
passenger3_eye_offset = def.passenger3_eye_offset,
|
|
||||||
passenger3_detach_pos_offset = def.passenger3_detach_pos_offset,
|
|
||||||
|
|
||||||
enable_crash = def.enable_crash,
|
enable_crash = def.enable_crash,
|
||||||
visual = def.visual,
|
visual = def.visual,
|
||||||
@ -103,21 +91,11 @@ function vehicle_mash.register_vehicle(name, def)
|
|||||||
else
|
else
|
||||||
self.object:set_armor_groups({fleshy = 0, immortal = 1}) -- Else, make vehicle immortal
|
self.object:set_armor_groups({fleshy = 0, immortal = 1}) -- Else, make vehicle immortal
|
||||||
end
|
end
|
||||||
|
|
||||||
if def.hp_min and def.hp_max then
|
if def.hp_min and def.hp_max then
|
||||||
self.object:set_hp(math.random(def.hp_min, def.hp_max), "Set HP to vehicle")
|
self.object:set_hp(math.random(def.hp_min, def.hp_max), "Set HP to vehicle")
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.driver then
|
|
||||||
self.driver:set_armor_groups({immortal = 0, fleshy = self.driver:get_armor_groups()})
|
|
||||||
end
|
|
||||||
-- Support for passengers
|
|
||||||
for i = 1, self.number_of_passengers do
|
|
||||||
local passenger = self.passengers[i]
|
|
||||||
if passenger.player then
|
|
||||||
passenger.player:set_armor_groups({immortal = 0, fleshy = passenger.player:get_armor_groups()})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local tmp = minetest.deserialize(staticdata)
|
local tmp = minetest.deserialize(staticdata)
|
||||||
if tmp then
|
if tmp then
|
||||||
for _,stat in pairs(tmp) do
|
for _,stat in pairs(tmp) do
|
||||||
|
65
init.lua
65
init.lua
@ -1,3 +1,5 @@
|
|||||||
|
vehicle_mash = { }
|
||||||
|
|
||||||
-- Fix `player_api` eye height model if desired
|
-- Fix `player_api` eye height model if desired
|
||||||
if minetest.settings:get_bool("vehicle_mash.player_api_fix") == true or minetest.settings:get_bool("vehicle_mash.player_api_fix") == nil then
|
if minetest.settings:get_bool("vehicle_mash.player_api_fix") == true or minetest.settings:get_bool("vehicle_mash.player_api_fix") == nil then
|
||||||
player_api.registered_models["character.b3d"].animations.sit.eye_height = 1.47
|
player_api.registered_models["character.b3d"].animations.sit.eye_height = 1.47
|
||||||
@ -62,14 +64,21 @@ else
|
|||||||
driver_attach_at = {x=3.5,y=3.7,z=3.5},
|
driver_attach_at = {x=3.5,y=3.7,z=3.5},
|
||||||
driver_eye_offset = {x=-4, y=0, z=0},
|
driver_eye_offset = {x=-4, y=0, z=0},
|
||||||
number_of_passengers = 3,
|
number_of_passengers = 3,
|
||||||
passenger_attach_at = {x=3.5,y=3.7,z=-3.5},
|
|
||||||
passenger_eye_offset = {x=4, y=0, z=0},
|
|
||||||
|
|
||||||
passenger2_attach_at = {x=-4,y=3.7,z=3.5},
|
passengers = {
|
||||||
passenger2_eye_offset = {x=-4, y=3, z=0},
|
{
|
||||||
|
attach_at = {x=3.5,y=3.7,z=-3.5},
|
||||||
passenger3_attach_at = {x=-4,y=3.7,z=-3.5},
|
eye_offset = {x=4, y=0, z=0},
|
||||||
passenger3_eye_offset = {x=4, y=3, z=0},
|
},
|
||||||
|
{
|
||||||
|
attach_at = {x=-4,y=3.7,z=3.5},
|
||||||
|
eye_offset = {x=-4, y=3, z=0},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
attach_at = {x=-4,y=3.7,z=-3.5},
|
||||||
|
eye_offset = {x=4, y=3, z=0},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
-- HP/Armor stuff. Uncomment to enable.
|
-- HP/Armor stuff. Uncomment to enable.
|
||||||
-- min_hp = 10,
|
-- min_hp = 10,
|
||||||
@ -91,7 +100,7 @@ else
|
|||||||
"nyan_ride", "oerkki_bliss", "road_master",
|
"nyan_ride", "oerkki_bliss", "road_master",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Load all CAR01's cars if enabled
|
-- Load all CAR01's cars if enabled
|
||||||
for _, name in ipairs(car01_names) do
|
for _, name in ipairs(car01_names) do
|
||||||
local check_enabled = minetest.settings:get_bool("vehicle_mash.enable_" .. name .. "_car")
|
local check_enabled = minetest.settings:get_bool("vehicle_mash.enable_" .. name .. "_car")
|
||||||
if check_enabled or check_enabled == nil then
|
if check_enabled or check_enabled == nil then
|
||||||
@ -123,14 +132,13 @@ else
|
|||||||
driver_attach_at = {x=0,y=0,z=-2.0},
|
driver_attach_at = {x=0,y=0,z=-2.0},
|
||||||
driver_eye_offset = {x=0, y=0, z=0},
|
driver_eye_offset = {x=0, y=0, z=0},
|
||||||
number_of_passengers = 0,
|
number_of_passengers = 0,
|
||||||
passenger_attach_at = {x=0,y=0,z=0},
|
|
||||||
passenger_eye_offset = {x=0, y=0, z=0},
|
|
||||||
|
|
||||||
passenger2_attach_at = {x=0,y=0,z=0},
|
passengers = {
|
||||||
passenger2_eye_offset = {x=0, y=0, z=0},
|
{
|
||||||
|
attach_at = {x=0,y=0,z=0},
|
||||||
passenger3_attach_at = {x=0,y=0,z=0},
|
eye_offset = {x=0, y=0, z=0},
|
||||||
passenger3_eye_offset = {x=0, y=0, z=0},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
-- HP/Armor stuff. Uncomment to enable.
|
-- HP/Armor stuff. Uncomment to enable.
|
||||||
-- min_hp = 10,
|
-- min_hp = 10,
|
||||||
@ -181,14 +189,12 @@ else
|
|||||||
driver_attach_at = {x=0.5,y=1,z=-3},
|
driver_attach_at = {x=0.5,y=1,z=-3},
|
||||||
driver_eye_offset = {x=0, y=0, z=0},
|
driver_eye_offset = {x=0, y=0, z=0},
|
||||||
number_of_passengers = 0,
|
number_of_passengers = 0,
|
||||||
passenger_attach_at = {x=0,y=0,z=0},
|
passengers = {
|
||||||
passenger_eye_offset = {x=0, y=0, z=0},
|
{
|
||||||
|
attach_at = {x=0,y=0,z=0},
|
||||||
passenger2_attach_at = {x=0,y=0,z=0},
|
eye_offset = {x=0, y=0, z=0},
|
||||||
passenger2_eye_offset = {x=0, y=0, z=0},
|
},
|
||||||
|
},
|
||||||
passenger3_attach_at = {x=0,y=0,z=0},
|
|
||||||
passenger3_eye_offset = {x=0, y=0, z=0},
|
|
||||||
|
|
||||||
-- HP/Armor stuff. Uncomment to enable.
|
-- HP/Armor stuff. Uncomment to enable.
|
||||||
-- min_hp = 10,
|
-- min_hp = 10,
|
||||||
@ -233,14 +239,13 @@ else
|
|||||||
driver_attach_at = {x=-2,y=6.3,z=0},
|
driver_attach_at = {x=-2,y=6.3,z=0},
|
||||||
driver_eye_offset = {x=0, y=0, z=0},
|
driver_eye_offset = {x=0, y=0, z=0},
|
||||||
number_of_passengers = 0,
|
number_of_passengers = 0,
|
||||||
passenger_attach_at = {x=0,y=0,z=0},
|
|
||||||
passenger_eye_offset = {x=0, y=0, z=0},
|
|
||||||
|
|
||||||
passenger2_attach_at = {x=0,y=0,z=0},
|
passengers = {
|
||||||
passenger2_eye_offset = {x=0, y=0, z=0},
|
{
|
||||||
|
attach_at = {x=0,y=0,z=0},
|
||||||
passenger3_attach_at = {x=0,y=0,z=0},
|
eye_offset = {x=0, y=0, z=0},
|
||||||
passenger3_eye_offset = {x=0, y=0, z=0},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
-- HP/Armor stuff. Uncomment to enable.
|
-- HP/Armor stuff. Uncomment to enable.
|
||||||
-- min_hp = 10,
|
-- min_hp = 10,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user