Cleanup and use vector.new where possible (#16)

This commit is contained in:
David Leal 2023-04-04 12:24:09 -06:00 committed by GitHub
parent 6b3141fd69
commit daa5845666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 49 deletions

View File

@ -11,5 +11,5 @@ read_globals = {
table = {fields = {"copy", "getn"}},
"minetest", "lib_mount",
"core",
"core", "vector"
}

View File

@ -1 +1,6 @@
Adds many types of vehicles.
Adds many types of vehicles:
- Normal cars.
- Boats.
- Hovercrafts.
- And mesecars.

View File

@ -37,7 +37,7 @@ function vehicle_mash.register_vehicle(name, def)
mouselook = false,
physical = true,
removed = false,
offset = {x=0, y=0, z=0},
offset = vector.new(0,0,0),
owner = "",
hp_min = def.hp_min,
hp_max = def.hp_max,
@ -145,7 +145,7 @@ function vehicle_mash.register_vehicle(name, def)
local passenger = self.passengers[i]
if passenger.player then
lib_mount.detach(passenger.player, passenger.eye_offset)
passenger.player:set_eye_offset({x = 0, y = 0, z = 0} ,{ x = 0, y = 0, z = 0 })
passenger.player:set_eye_offset(vector.new(0,0,0), vector.new(0,0,0))
end
end
end

View File

@ -1,7 +1,9 @@
vehicle_mash = { }
-- 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
and player_api.registered_models["character.b3d"] then
player_api.registered_models["character.b3d"].animations.sit.eye_height = 1.47
end
@ -56,27 +58,27 @@ else
visual = "mesh",
mesh = "car.x",
visual_size = {x=1, y=1},
wield_scale = {x=1, y=1, z=1},
wield_scale = vector.new(1,1,1),
collisionbox = {-0.6, -0.05, -0.6, 0.6, 1, 0.6},
onplace_position_adj = -0.45,
-- player specific stuff
player_rotation = {x=0,y=90,z=0},
driver_attach_at = {x=3.5,y=3.7,z=3.5},
driver_eye_offset = {x=-4, y=0, z=0},
player_rotation = vector.new(0,90,0),
driver_attach_at = vector.new(3.5,3.7,3.5),
driver_eye_offset = vector.new(-4,0,0),
number_of_passengers = 3,
passengers = {
{
attach_at = {x=3.5,y=3.7,z=-3.5},
eye_offset = {x=4, y=0, z=0},
attach_at = vector.new(3.5,3.7,-3.5),
eye_offset = vector.new(4,0,0),
},
{
attach_at = {x=-4,y=3.7,z=3.5},
eye_offset = {x=-4, y=3, z=0},
attach_at = vector.new(-4,3.7,3.5),
eye_offset = vector.new(-4,3,0),
},
{
attach_at = {x=-4,y=3.7,z=-3.5},
eye_offset = {x=4, y=3, z=0},
attach_at = vector.new(-4,3.7,-3.5),
eye_offset = vector.new(4,3,0),
},
},
@ -124,19 +126,19 @@ else
visual = "cube",
mesh = "",
visual_size = {x=1.5, y=1.5},
wield_scale = {x=1, y=1, z=1},
wield_scale = vector.new(1,1,1),
collisionbox = {-0.75, -0.75, -0.75, 0.75, 0.75, 0.75},
onplace_position_adj = 0.25,
-- player specific stuff
player_rotation = {x=0,y=0,z=0},
driver_attach_at = {x=0,y=0,z=-2.0},
driver_eye_offset = {x=0, y=0, z=0},
player_rotation = vector.new(0,0,0),
driver_attach_at = vector.new(0,0,-2.0),
driver_eye_offset = vector.new(0,0,0),
number_of_passengers = 0,
passengers = {
{
attach_at = {x=0,y=0,z=0},
eye_offset = {x=0, y=0, z=0},
attach_at = vector.new(0,0,0),
eye_offset = vector.new(0,0,0),
},
},
@ -180,19 +182,19 @@ else
-- model specific stuff
visual = "mesh",
visual_size = {x=1, y=1},
wield_scale = {x=1, y=1, z=1},
wield_scale = vector.new(1,1,1),
collisionbox = {-0.5, -0.35, -0.5, 0.5, 0.3, 0.5},
onplace_position_adj = 0,
textures = {"default_wood.png"},
-- player specific stuff
player_rotation = {x=0, y=0, z=0},
driver_attach_at = {x=0.5,y=1,z=-3},
driver_eye_offset = {x=0, y=0, z=0},
player_rotation = vector.new(0,0,0),
driver_attach_at = vector.new(0.5,1,-3),
driver_eye_offset = vector.new(0,0,0),
number_of_passengers = 0,
passengers = {
{
attach_at = {x=0,y=0,z=0},
eye_offset = {x=0, y=0, z=0},
attach_at = vector.new(0,0,0),
eye_offset = vector.new(0,0,0),
},
},
@ -231,19 +233,19 @@ else
visual = "mesh",
mesh = "hovercraft.x",
visual_size = {x=1, y=1},
wield_scale = {x=1, y=1, z=1},
wield_scale = vector.new(1,1,1),
collisionbox = {-0.8, -0.25, -0.8, 0.8, 1.2, 0.8},
onplace_position_adj = -0.25,
-- player specific stuff
player_rotation = {x=0,y=90,z=0},
driver_attach_at = {x=-2,y=6.3,z=0},
driver_eye_offset = {x=0, y=0, z=0},
player_rotation = vector.new(0,90,0),
driver_attach_at = vector.new(-2,6.3,0),
driver_eye_offset = vector.new(0,0,0),
number_of_passengers = 0,
passengers = {
{
attach_at = {x=0,y=0,z=0},
eye_offset = {x=0, y=0, z=0},
attach_at = vector.new(0,0,0),
eye_offset = vector.new(0,0,0),
},
},

View File

@ -9,3 +9,4 @@ Adds many types of vehicles:
- Hovercrafts.
- And mesecars.
"""
min_minetest_version = 5.0.0

View File

@ -9,25 +9,30 @@ local definition = {
can_fly = false, -- if enabled, the specified vehicle will be able to fly around
can_go_down = false, -- applies only when `can_fly` is enabled
can_go_up = false, -- applies only when `can_fly` is enabled
player_rotation = {x=0,y=0,z=0}, -- rotate player so they sit facing the correct direction
driver_attach_at = {x=0,y=0,z=0}, -- attach the driver at
driver_eye_offset = {x=0, y=0, z=0}, -- offset for first person driver view
number_of_passengers = 0, -- maximum number of passengers. Can have 3 passengers maximum
passenger_attach_at = {x=0,y=0,z=0}, -- attach the 1st passenger, if applicable, at the specified positions
passenger_eye_offset = {x=0, y=0, z=0}, -- offset for the 1st passenger in first-person view
passenger_detach_pos_offset = {x=0,y=0,z=0}, -- offset for the 1st passenger when they leave the vehicle
player_rotation = vector.new(0,0,0), -- rotate player so they sit facing the correct direction
driver_attach_at = vector.new(0,0,0), -- attach the driver at
driver_eye_offset = vector.new(0,0,0), -- offset for first person driver view
number_of_passengers = 0, -- maximum number of passengers. Can have 3 passengers maximum
passenger2_attach_at = {x=0,y=0,z=0}, -- attach the 2nd passenger, if applicable, at the specified positions
passenger2_eye_offset = {x=0,y=0,z=0}, -- offset for the 2nd passenger in first-person view
passenger2_detach_pos_offset = {x=0,y=0,z=0}, -- offset for the 2nd passenger when they leave the vehicle
passenger3_attach_at = {x=0,y=0,z=0}, -- attach the 3rd passenger, if applicable, at the specified positions
passenger3_eye_offset = {x=0,y=0,z=0}, -- offset for the 3rd passenger in first-person view
passenger3_detach_pos_offset = {x=0,y=0,z=0}, -- offset for the 3rd passenger when they leave the vehicle
-- Attachment positions and offset for all passengers (can be over 3 passengers)
passengers = {
{
attach_at = vector.new(0,0,0),
eye_offset = vector.new(0,0,0),
},
{
attach_at = vector.new(0,0,0),
eye_offset = vector.new(0,0,0),
},
{
attach_at = vector.new(0,0,0),
eye_offset = vector.new(0,0,0),
},
},
inventory_image = "filename.png", -- image to use in inventory
wield_image = "filename.png", -- image to use in hand
wield_scale = {x=1, y=1, z=1}, --
wield_scale = vector.new(1,1,1), -- the size of the item in hand
visual = "mesh", -- what type of object (mesh, cube, etc...)
mesh = "filename.ext", -- mesh model to use
textures = {"filename.png"}, -- mesh texture(s)
@ -41,7 +46,11 @@ local definition = {
braking = 2, -- how fast can the vehicle stop
turn_speed = 2, -- how quick can the vehicle turn
drop_on_destroy = {""}, -- what gets dropped when vehicle is destroyed
recipe = {} -- crafting recipe
recipe = {}, -- crafting recipe
-- HP/Armor stuff.
min_hp = 1,
max_hp = 10,
armor = 25
}
-- nothing to change down here