a few updates
-some speed adjustments, -removed a couple unused functions, -removed is_boat in favor of terrain_type, -added the blue hovercraft for testing which prompted a few tweaks here and there
This commit is contained in:
parent
1f02597926
commit
be63ee8305
2
126r.lua
2
126r.lua
@ -4,7 +4,7 @@ local definition = ...
|
||||
|
||||
definition.description = "126r car"
|
||||
-- adjust to change how vehicle reacts while driving
|
||||
definition.max_speed_forward = 20
|
||||
definition.max_speed_forward = 12
|
||||
definition.max_speed_reverse = 10
|
||||
definition.accel = 3
|
||||
definition.braking = 6
|
||||
|
@ -39,7 +39,6 @@ v2.0 8/13/2016
|
||||
- converted to use the lib_mount mod for "driving"
|
||||
- enlarged F1 and 126r models x2.5
|
||||
- added yellow Mesecar
|
||||
- updated boat model from default boat mod
|
||||
- various speed/braking/turning/acceleration tweaks
|
||||
- various collision box tweaks
|
||||
- various other tweaks I probably forgot about
|
||||
|
2
crafts.lua
Normal file
2
crafts.lua
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
|
4
f1.lua
4
f1.lua
@ -4,8 +4,8 @@ local definition = ...
|
||||
|
||||
definition.description = "F1 car"
|
||||
-- adjust to change how vehicle reacts while driving
|
||||
definition.max_speed_forward = 25
|
||||
definition.max_speed_reverse = 15
|
||||
definition.max_speed_forward = 15
|
||||
definition.max_speed_reverse = 7
|
||||
definition.accel = 4
|
||||
definition.braking = 8
|
||||
definition.turn_speed = 4
|
||||
|
@ -1,18 +1,6 @@
|
||||
|
||||
vehicle_mash = {}
|
||||
|
||||
local function get_velocity_a(v, yaw, y)
|
||||
local x = math.cos(yaw) * v
|
||||
local z = math.sin(yaw) * v
|
||||
return {x=x, y=y, z=z}
|
||||
end
|
||||
|
||||
local function get_velocity_b(v, yaw, y)
|
||||
local x = -math.sin(yaw) * v
|
||||
local z = math.cos(yaw) * v
|
||||
return {x=x, y=y, z=z}
|
||||
end
|
||||
|
||||
local function is_water(pos)
|
||||
local nn = minetest.get_node(pos).name
|
||||
return minetest.get_item_group(nn, "water") ~= 0
|
||||
@ -22,8 +10,8 @@ local drive = lib_mount.drive
|
||||
|
||||
function vehicle_mash.register_vehicle(name, def)
|
||||
minetest.register_entity(name, {
|
||||
terrain_type = def.terrain_type,
|
||||
collisionbox = def.collisionbox,
|
||||
is_boat = def.is_boat,
|
||||
player_rotation = def.player_rotation,
|
||||
driver_attach_at = def.driver_attach_at,
|
||||
driver_eye_offset = def.driver_eye_offset,
|
||||
@ -38,8 +26,8 @@ function vehicle_mash.register_vehicle(name, def)
|
||||
tiles = def.tiles,
|
||||
visual_size = def.visual_size,
|
||||
stepheight = def.stepheight,
|
||||
max_spd_f = def.max_speed_forward,
|
||||
max_spd_r = def.max_speed_reverse,
|
||||
max_speed_forward = def.max_speed_forward,
|
||||
max_speed_reverse = def.max_speed_reverse,
|
||||
accel = def.accel,
|
||||
braking = def.braking,
|
||||
turn_spd = def.turn_speed,
|
||||
@ -48,18 +36,15 @@ function vehicle_mash.register_vehicle(name, def)
|
||||
passenge = nil,
|
||||
v = 0,
|
||||
v2 = 0,
|
||||
mouselook = 1,
|
||||
mouselook = false,
|
||||
physical = true,
|
||||
removed = false,
|
||||
offset = {x=0, y=0, z=0},
|
||||
owner = "",
|
||||
on_rightclick = function(self, clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
-- owner set to the player?
|
||||
if not self.owner or self.owner == "" then
|
||||
self.owner = clicker:get_player_name()
|
||||
end
|
||||
-- if there is already a driver
|
||||
if self.driver then
|
||||
-- if clicker is driver detach passenger and driver
|
||||
@ -117,8 +102,9 @@ function vehicle_mash.register_vehicle(name, def)
|
||||
if not puncher or not puncher:is_player() or self.removed or self.driver then
|
||||
return
|
||||
end
|
||||
if self.owner == puncher:get_player_name()
|
||||
or minetest.get_player_privs(puncher:get_player_name(), {basic_privs=true}) then
|
||||
local punchername = puncher:get_player_name()
|
||||
if self.owner == punchername
|
||||
or minetest.get_player_privs(punchername, {basic_privs=true}) then
|
||||
self.removed = true
|
||||
-- delay remove to ensure player is detached
|
||||
minetest.after(0.1, function()
|
||||
@ -132,34 +118,44 @@ function vehicle_mash.register_vehicle(name, def)
|
||||
end
|
||||
})
|
||||
|
||||
local onplace_position_adj = def.onplace_position_adj
|
||||
local can_float = false
|
||||
if def.terrain_type == 2 or def.terrain_type == 3 then
|
||||
can_float = true
|
||||
end
|
||||
|
||||
minetest.register_craftitem(name, {
|
||||
description = def.description,
|
||||
inventory_image = def.inventory_image,
|
||||
wield_image = def.wield_image,
|
||||
wield_scale = def.wield_scale,
|
||||
liquids_pointable = def.is_boat,
|
||||
liquids_pointable = can_float,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
local ent
|
||||
if def.is_boat then
|
||||
if is_water(pointed_thing.under) then
|
||||
if minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "liquid") == 0 then
|
||||
if def.terrain_type == 0 or def.terrain_type == 1 or def.terrain_type == 3 then
|
||||
pointed_thing.above.y = pointed_thing.above.y + def.onplace_position_adj
|
||||
ent = minetest.add_entity(pointed_thing.above, name)
|
||||
else
|
||||
return
|
||||
end
|
||||
else
|
||||
if def.terrain_type == 2 or def.terrain_type == 3 then
|
||||
pointed_thing.under.y = pointed_thing.under.y + 0.5
|
||||
ent = minetest.add_entity(pointed_thing.under, name)
|
||||
else
|
||||
return
|
||||
end
|
||||
else
|
||||
pointed_thing.above.y = pointed_thing.above.y + onplace_position_adj
|
||||
ent = minetest.add_entity(pointed_thing.above, name)
|
||||
|
||||
end
|
||||
if ent:get_luaentity().player_rotation.y == 90 then
|
||||
ent:setyaw(placer:get_look_yaw())
|
||||
else
|
||||
ent:setyaw(placer:get_look_yaw() - math.pi/2)
|
||||
end
|
||||
ent:get_luaentity().owner = placer:get_player_name()
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
|
@ -1,32 +1,11 @@
|
||||
|
||||
local name = "hover_blue"
|
||||
|
||||
local definition = {
|
||||
description = "Blue hovercraft",
|
||||
collisionbox = {-0.8,0,-0.8, 0.8,1.2,0.8},
|
||||
onplace_position_adj = 0,
|
||||
is_boat = false,
|
||||
player_rotation = {x=0,y=90,z=0},
|
||||
driver_attach_at = {x=-2,y=16.5,z=0},
|
||||
number_of_passengers = 0,
|
||||
passenger_attach_at = {x=0,y=0,z=0},
|
||||
passenger_eye_offset = {x=0, y=0, z=0},
|
||||
driver_eye_offset = {x=0, y=0, z=0},
|
||||
inventory_image = "hovercraft_blue_inv.png",
|
||||
wield_image = "hovercraft_blue_inv.png",
|
||||
wield_scale = {x=1, y=1, z=1},
|
||||
visual = "mesh",
|
||||
mesh = "hovercraft.x",
|
||||
textures = {"hovercraft_blue.png"},
|
||||
visual_size = {x=1, y=1},
|
||||
stepheight = 0.6,
|
||||
max_speed_forward = 12,
|
||||
max_speed_reverse = 0,
|
||||
accel = 2.5,
|
||||
braking = 1,
|
||||
turn_speed = 2,
|
||||
drop_on_destroy = "",
|
||||
recipe = {}
|
||||
}
|
||||
local definition = ...
|
||||
|
||||
definition.description = "Blue hovercraft"
|
||||
definition.inventory_image = "hovercraft_blue_inv.png"
|
||||
definition.wield_image = "hovercraft_blue_inv.png"
|
||||
definition.textures = {"hovercraft_blue.png"}
|
||||
|
||||
vehicle_mash.register_vehicle("vehicle_mash:"..name, definition)
|
||||
|
114
init.lua
114
init.lua
@ -5,7 +5,8 @@ local mpath = minetest.get_modpath("vehicle_mash")
|
||||
-- load framework
|
||||
dofile(mpath.."/framework.lua")
|
||||
|
||||
local common_def = {}
|
||||
-- load crafts
|
||||
--dofile(mpath.."/crafts.lua")
|
||||
|
||||
-- ***********************
|
||||
-- load vehicles down here
|
||||
@ -14,9 +15,10 @@ local common_def = {}
|
||||
-- ** 126r and F1 **
|
||||
------------------------------------------------------------------------------
|
||||
-- create Cars common def
|
||||
common_def = {
|
||||
local cars_def = {
|
||||
--adjust to change how vehicle reacts while driving
|
||||
terrain_type = 1, -- 0 = air, 1 = land, 2 = liquid, 3 = land + liquid
|
||||
--model specific stuff
|
||||
is_boat = false,
|
||||
visual = "mesh",
|
||||
visual_size = {x=1, y=1},
|
||||
wield_scale = {x=1, y=1, z=1},
|
||||
@ -33,23 +35,23 @@ common_def = {
|
||||
|
||||
-- vehicle specific values in the following files
|
||||
-- you can override any common values from here
|
||||
loadfile(mpath.."/126r.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/f1.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/126r.lua")(table.copy(cars_def))
|
||||
loadfile(mpath.."/f1.lua")(table.copy(cars_def))
|
||||
|
||||
|
||||
-- ** CAR01s **
|
||||
------------------------------------------------------------------------------
|
||||
-- create CAR01 common def
|
||||
common_def = {
|
||||
local car01_def = {
|
||||
--adjust to change how vehicle reacts while driving
|
||||
terrain_type = 1,
|
||||
max_speed_forward = 10,
|
||||
max_speed_reverse = 5,
|
||||
max_speed_reverse = 7,
|
||||
accel = 2,
|
||||
braking = 4,
|
||||
turn_speed = 2,
|
||||
stepheight = 1.1,
|
||||
--model specific stuff
|
||||
is_boat = false,
|
||||
visual = "mesh",
|
||||
mesh = "car.x",
|
||||
visual_size = {x=1, y=1},
|
||||
@ -70,40 +72,40 @@ common_def = {
|
||||
|
||||
-- vehicle specific values in the following files
|
||||
-- you can override any common values from here
|
||||
loadfile(mpath.."/black.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/blue.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/brown.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/cyan.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/dark_green.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/dark_grey.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/green.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/grey.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/magenta.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/orange.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/pink.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/red.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/violet.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/white.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/yellow.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/hot_rod.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/nyan_ride.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/oerkki_bliss.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/road_master.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/black.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/blue.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/brown.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/cyan.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/dark_green.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/dark_grey.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/green.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/grey.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/magenta.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/orange.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/pink.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/red.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/violet.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/white.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/yellow.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/hot_rod.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/nyan_ride.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/oerkki_bliss.lua")(table.copy(car01_def))
|
||||
loadfile(mpath.."/road_master.lua")(table.copy(car01_def))
|
||||
|
||||
|
||||
-- ** MeseCars **
|
||||
------------------------------------------------------------------------------
|
||||
-- create Mesecar common def
|
||||
common_def = {
|
||||
local mesecar_def = {
|
||||
--adjust to change how vehicle reacts while driving
|
||||
max_speed_forward = 15,
|
||||
terrain_type = 1,
|
||||
max_speed_forward = 10,
|
||||
max_speed_reverse = 7,
|
||||
accel = 3,
|
||||
braking = 6,
|
||||
turn_speed = 4,
|
||||
stepheight = 0.6,
|
||||
--model specific stuff
|
||||
is_boat = false,
|
||||
visual = "cube",
|
||||
mesh = "",
|
||||
visual_size = {x=1.5, y=1.5},
|
||||
@ -124,17 +126,18 @@ common_def = {
|
||||
|
||||
-- vehicle specific values in the following files
|
||||
-- you can override any common values from here
|
||||
loadfile(mpath.."/mese_blue.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/mese_pink.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/mese_purple.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/mese_Yellow.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/mese_blue.lua")(table.copy(mesecar_def))
|
||||
loadfile(mpath.."/mese_pink.lua")(table.copy(mesecar_def))
|
||||
loadfile(mpath.."/mese_purple.lua")(table.copy(mesecar_def))
|
||||
loadfile(mpath.."/mese_Yellow.lua")(table.copy(mesecar_def))
|
||||
|
||||
|
||||
-- ** Boats **
|
||||
------------------------------------------------------------------------------
|
||||
-- create boats common def
|
||||
common_def = {
|
||||
local boat_def = {
|
||||
--adjust to change how vehicle reacts while driving
|
||||
terrain_type = 2,
|
||||
max_speed_forward = 3,
|
||||
max_speed_reverse = 3,
|
||||
accel = 3,
|
||||
@ -142,7 +145,6 @@ common_def = {
|
||||
turn_speed = 3,
|
||||
stepheight = 0,
|
||||
--model specific stuff
|
||||
is_boat = true,
|
||||
visual = "mesh",
|
||||
visual_size = {x=1, y=1},
|
||||
wield_scale = {x=1, y=1, z=1},
|
||||
@ -160,12 +162,44 @@ common_def = {
|
||||
|
||||
-- vehicle specific values in the following files
|
||||
-- you can override any common values from here
|
||||
loadfile(mpath.."/boat.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/rowboat.lua")(table.copy(common_def))
|
||||
loadfile(mpath.."/boat.lua")(table.copy(boat_def))
|
||||
loadfile(mpath.."/rowboat.lua")(table.copy(boat_def))
|
||||
|
||||
|
||||
-- Hovercraft
|
||||
--dofile(mpath.."/hover_blue.lua")
|
||||
-- ** Hovercraft **
|
||||
------------------------------------------------------------------------------
|
||||
-- create hovercraft common def
|
||||
local hover_def = {
|
||||
--adjust to change how vehicle reacts while driving
|
||||
terrain_type = 3,
|
||||
max_speed_forward = 10,
|
||||
max_speed_reverse = 0,
|
||||
accel = 3,
|
||||
braking = 1,
|
||||
turn_speed = 2,
|
||||
stepheight = 1.1,
|
||||
--model specific stuff
|
||||
visual = "mesh",
|
||||
mesh = "hovercraft.x",
|
||||
visual_size = {x=1, y=1},
|
||||
wield_scale = {x=1, y=1, z=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=16.5,z=0},
|
||||
driver_eye_offset = {x=0, y=0, z=0},
|
||||
number_of_passengers = 0,
|
||||
passenger_attach_at = {x=0,y=0,z=0},
|
||||
passenger_eye_offset = {x=0, y=0, z=0},
|
||||
--drop and recipe
|
||||
drop_on_destroy = "",
|
||||
recipe = nil
|
||||
}
|
||||
|
||||
-- vehicle specific values in the following files
|
||||
-- you can override any common values from here
|
||||
loadfile(mpath.."/hover_blue.lua")(table.copy(hover_def))
|
||||
|
||||
-- free unneeded global(s)
|
||||
core.after(10, function()
|
||||
|
Loading…
x
Reference in New Issue
Block a user