Big update
>added driving sound for cars >added accelleration for cars >vehicles require ammo for weapons >planes can no longer fly backwards >vehicles slow down in water >fixed an error in the parachute >vehicles explode when destroyed >stairs dependancy is now optional >vehicles can be removed and picked up if there is no driver >fixed the jet flying away after exiting >added crafting recipes and materials changes thanks to Wuzzy: >added setting vehicles_nodes = true/false >added sound to basic nodes >made tyres fall >changed tunnel lights texture
269
api.lua
@ -105,16 +105,37 @@ end)
|
||||
|
||||
--mixed code(from this mod and lib_mount)
|
||||
|
||||
|
||||
timer = 0
|
||||
|
||||
--basic driving, use for basic vehicles/mounts, with optional weapons
|
||||
function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, moving_anim, stand_anim, jumps)
|
||||
--variables
|
||||
local ctrl = entity.driver:get_player_control()
|
||||
local velo = entity.object:getvelocity()
|
||||
local dir = entity.driver:get_look_dir();
|
||||
local vec_forward = {x=dir.x*speed,y=velo.y+1*-2,z=dir.z*speed}
|
||||
--local vec_forward = {x=dir.x*speed,y=velo.y+1*-2,z=dir.z*speed}
|
||||
local vec_backward = {x=-dir.x*speed,y=velo.y+1*-2,z=-dir.z*speed}
|
||||
local vec_stop = {x=velo.x*decell,y=velo.y+1*-2,z=velo.z*decell}
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
if ctrl.up then
|
||||
--timer
|
||||
local absolute_speed = math.sqrt(math.pow(velo.x, 2)+math.pow(velo.z, 2))
|
||||
if absolute_speed <= speed and ctrl.up then
|
||||
timer = timer + 1*dtime
|
||||
end
|
||||
if not ctrl.up then
|
||||
timer = 0
|
||||
end
|
||||
--timer dependant variables
|
||||
local vec_forward = {x=dir.x*speed/4*math.atan(0.5*timer-2)+8*dir.x,y=velo.y+1*-2,z=dir.z*speed/4*math.atan(0.5*timer-2)+8*dir.z}
|
||||
|
||||
--respond to controls
|
||||
--water effects
|
||||
local pos = entity.object:getpos()
|
||||
local node = minetest.get_node(pos).name
|
||||
if node == "default:water_source" or node == "default:river_water_source" or node == "default:river_water_flowing" or node == "default:water_flowing" then
|
||||
entity.object:setvelocity({x=velo.x*0.9, y=-1, z=velo.z*0.9})
|
||||
elseif ctrl.up then
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
entity.object:setvelocity(vec_forward)
|
||||
elseif ctrl.down then
|
||||
@ -125,6 +146,10 @@ function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, movin
|
||||
entity.object:setvelocity(vec_stop)
|
||||
end
|
||||
if ctrl.sneak and shoots and entity.loaded then
|
||||
local pname = entity.driver:get_player_name();
|
||||
local inv = minetest.get_inventory({type="player", name=pname});
|
||||
if inv:contains_item("main", arrow.."_item") or arrow == "vehicles:water" then
|
||||
local remov = inv:remove_item("main", arrow.."_item")
|
||||
entity.loaded = false
|
||||
local pos = entity.object:getpos()
|
||||
local obj = minetest.env:add_entity({x=pos.x+0+dir.x*2,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2}, arrow)
|
||||
@ -137,6 +162,7 @@ function object_drive(entity, dtime, speed, decell, shoots, arrow, reload, movin
|
||||
minetest.after(reload, function()
|
||||
entity.loaded = true
|
||||
end)
|
||||
end
|
||||
end
|
||||
--lib_mount animation
|
||||
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||
@ -187,15 +213,38 @@ function object_drive_simple(entity, dtime, speed, decell)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--same as above but with improvements for cars and nitro/boost
|
||||
function object_drive_car(entity, dtime, speed, decell, nitro_duration)
|
||||
local ctrl = entity.driver:get_player_control()
|
||||
local velo = entity.object:getvelocity()
|
||||
local dir = entity.driver:get_look_dir();
|
||||
local vec_forward = {x=dir.x*speed,y=velo.y-0.5,z=dir.z*speed}
|
||||
local vec_nitro = {x=dir.x*(speed*1.5),y=velo.y-0.5,z=dir.z*(speed*1.5)}
|
||||
local vec_backward = {x=-dir.x*speed,y=velo.y-0.5,z=-dir.z*speed}
|
||||
local dir = entity.driver:get_look_dir()
|
||||
--speed indicator
|
||||
--minetest.chat_send_player(entity.driver:get_player_name(), ""..velocity.."")
|
||||
|
||||
--timer
|
||||
local absolute_speed = math.sqrt(math.pow(velo.x, 2)+math.pow(velo.z, 2))
|
||||
if absolute_speed <= speed and ctrl.up then
|
||||
timer = timer + 1*dtime
|
||||
end
|
||||
if not ctrl.up then
|
||||
timer = 0
|
||||
end
|
||||
|
||||
--stuff left behind for future
|
||||
--local xaccell = math.abs(math.atan(velo.x))
|
||||
--local zaccell = math.abs(math.atan(velo.z))
|
||||
local accell = 1
|
||||
|
||||
--vectors
|
||||
local vec_forward = {x=dir.x*speed/4*math.atan(0.5*timer-2)+8*dir.x,y=velo.y-0.5,z=dir.z*speed/4*math.atan(0.5*timer-2)+8*dir.z}
|
||||
--local vec_forward = {x=dir.x*speed*accell,y=velo.y-0.5,z=dir.z*speed*accell}
|
||||
--local vec_nitro = {x=dir.x*(speed*1.5)*accell,y=velo.y-0.5,z=dir.z*(speed*1.5)*accell}
|
||||
local vec_nitro = {x=dir.x*speed*2/4*math.atan(timer-2)+5*dir.x,y=velo.y-0.5,z=dir.z*speed*2/4*math.atan(timer-2)+5*dir.z}
|
||||
local vec_backward = {x=-dir.x*(speed/4)*accell,y=velo.y-0.5,z=-dir.z*(speed/4)*accell}
|
||||
local vec_stop = {x=velo.x*decell,y=velo.y-1,z=velo.z*decell}
|
||||
|
||||
--face the right way
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
if not entity.nitro then
|
||||
@ -203,7 +252,13 @@ function object_drive_car(entity, dtime, speed, decell, nitro_duration)
|
||||
entity.nitro = true
|
||||
end)
|
||||
end
|
||||
if ctrl.up and ctrl.sneak and entity.nitro then
|
||||
--respond to controls
|
||||
--water effects
|
||||
local pos = entity.object:getpos()
|
||||
local node = minetest.get_node(pos).name
|
||||
if node == "default:water_source" or node == "default:river_water_source" or node == "default:river_water_flowing" or node == "default:water_flowing" then
|
||||
entity.object:setvelocity({x=velo.x*0.9, y=-1, z=velo.z*0.9})
|
||||
elseif ctrl.up and ctrl.sneak and entity.nitro then
|
||||
entity.object:setvelocity(vec_nitro)
|
||||
local pos = entity.object:getpos()
|
||||
minetest.add_particlespawner(
|
||||
@ -232,6 +287,15 @@ function object_drive_car(entity, dtime, speed, decell, nitro_duration)
|
||||
elseif not ctrl.down or ctrl.up then
|
||||
entity.object:setvelocity(vec_stop)
|
||||
end
|
||||
--play engine sound
|
||||
if entity.sound_ready then
|
||||
minetest.sound_play("engine",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
entity.sound_ready = false
|
||||
minetest.after(11, function()
|
||||
entity.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
--for boats and watercraft
|
||||
@ -259,62 +323,7 @@ function object_float(entity, dtime, speed, decell)
|
||||
end
|
||||
|
||||
--attempts to improve object_drive_car
|
||||
-- function object_drive_experimental(entity, dtime, power, traction, nitro_duration)
|
||||
-- local ctrl = entity.driver:get_player_control()
|
||||
-- local velo = entity.object:getvelocity()
|
||||
-- local speed = math.abs(velo.x)+math.abs(velo.z)
|
||||
-- local nitro_remaining = entity.nitro
|
||||
-- local dir = entity.driver:get_look_dir()
|
||||
-- local yaw1 = entity.object:getyaw()
|
||||
-- local dir_x = -math.sin(yaw1)
|
||||
-- local dir_z = math.cos(yaw1)
|
||||
-- local vec_forward = {x=dir_x*power,y=velo.y-0.5,z=dir_z*power}
|
||||
-- local vec_nitro = {x=dir.x*(power*1.5),y=velo.y-0.5,z=dir.z*(power*1.5)}
|
||||
-- local vec_backward = {x=-dir.x*power,y=velo.y-0.5,z=-dir.z*power}
|
||||
-- local vec_stop = {x=velo.x*traction,y=velo.y-1,z=velo.z*traction}
|
||||
-- local yaw = entity.driver:get_look_yaw();
|
||||
-- if ctrl.left then
|
||||
-- entity.object:setyaw(yaw1+math.pi/180+speed/360)
|
||||
-- elseif ctrl.right then
|
||||
-- entity.object:setyaw(yaw1-math.pi/180-speed/360)
|
||||
-- else
|
||||
-- entity.object:setyaw(yaw1)
|
||||
-- end
|
||||
-- if not entity.nitro then
|
||||
-- minetest.after(4, function()
|
||||
-- entity.nitro = true
|
||||
-- end)
|
||||
-- end
|
||||
-- if ctrl.up and ctrl.sneak and entity.nitro then
|
||||
-- entity.object:setvelocity(vec_nitro)
|
||||
-- local pos = entity.object:getpos()
|
||||
-- minetest.add_particlespawner(
|
||||
-- 15, --amount
|
||||
-- 1, --time
|
||||
-- {x=pos.x-0.5, y=pos.y, z=pos.z-0.5}, --minpos
|
||||
-- {x=pos.x+0.5, y=pos.y, z=pos.z+0.5}, --maxpos
|
||||
-- {x=0, y=0, z=0}, --minvel
|
||||
-- {x=-velo.x, y=-velo.y, z=-velo.z}, --maxvel
|
||||
-- {x=-0,y=-0,z=-0}, --minacc
|
||||
-- {x=0,y=0,z=0}, --maxacc
|
||||
-- 0.1, --minexptime
|
||||
-- 0.2, --maxexptime
|
||||
-- 10, --minsize
|
||||
-- 15, --maxsize
|
||||
-- false, --collisiondetection
|
||||
-- "vehicles_nitro.png" --texture
|
||||
-- )
|
||||
-- minetest.after(nitro_duration, function()
|
||||
-- entity.nitro = false
|
||||
-- end)
|
||||
-- elseif ctrl.up then
|
||||
-- entity.object:setvelocity(vec_forward)
|
||||
-- elseif ctrl.down then
|
||||
-- entity.object:setvelocity(vec_backward)
|
||||
-- elseif not ctrl.down or ctrl.up then
|
||||
-- entity.object:setvelocity(vec_stop)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
--stationary object, useful for gun turrets etc.
|
||||
function object_turret(entity, dtime, height, arrow, shoot_interval)
|
||||
@ -322,6 +331,10 @@ function object_turret(entity, dtime, height, arrow, shoot_interval)
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
if ctrl.sneak and entity.loaded then
|
||||
local pname = entity.driver:get_player_name();
|
||||
local inv = minetest.get_inventory({type="player", name=pname});
|
||||
if inv:contains_item("main", arrow.."_item") then
|
||||
local remov = inv:remove_item("main", arrow.."_item")
|
||||
entity.loaded = false
|
||||
local pos = entity.object:getpos()
|
||||
local dir = entity.driver:get_look_dir();
|
||||
@ -335,32 +348,40 @@ function object_turret(entity, dtime, height, arrow, shoot_interval)
|
||||
minetest.after(shoot_interval, function()
|
||||
entity.loaded = true
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--basic flying, with optional weapons
|
||||
function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, moving_anim, stand_anim)
|
||||
function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, reload, moving_anim, stand_anim)
|
||||
local ctrl = entity.driver:get_player_control()
|
||||
local dir = entity.driver:get_look_dir();
|
||||
local velo = entity.object:getvelocity()
|
||||
local vec_forward = {x=dir.x*speed,y=(dir.y*speed)/4+math.abs(velo.z+velo.x)/10,z=dir.z*speed}
|
||||
local acc_forward = {x=dir.x*accel/2,y=dir.y*accel/2+3,z=dir.z*accel/2}
|
||||
local vec_backward = {x=-dir.x*speed,y=dir.y*speed+3,z=-dir.z*speed}
|
||||
local acc_backward = {x=dir.x*accel/2,y=dir.y*accel/2+3,z=dir.z*accel/2}
|
||||
--local vec_backward = {x=-dir.x*speed,y=dir.y*speed+3,z=-dir.z*speed}
|
||||
--local acc_backward = {x=dir.x*accel/2,y=dir.y*accel/2+3,z=dir.z*accel/2}
|
||||
local vec_stop = {x=velo.x*decell, y=velo.y, z=velo.z*decell}
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
--pitch doesn't work
|
||||
--pitch doesn't work/exist
|
||||
--local pitch = entity.driver:get_look_pitch();
|
||||
if ctrl.up then
|
||||
|
||||
|
||||
--water effects
|
||||
local pos = entity.object:getpos()
|
||||
local node = minetest.get_node(pos).name
|
||||
if node == "default:water_source" or node == "default:river_water_source" or node == "default:river_water_flowing" or node == "default:water_flowing" then
|
||||
entity.object:setvelocity({x=velo.x*0.9, y=-1, z=velo.z*0.9})
|
||||
elseif ctrl.up then
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
--entity.object:setpitch(pitch+math.pi+math.pi/2)
|
||||
entity.object:setvelocity(vec_forward)
|
||||
entity.object:setacceleration(acc_forward)
|
||||
elseif ctrl.down then
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
--elseif ctrl.down then
|
||||
--entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
--entity.object:setpitch(pitch+math.pi+math.pi/2)
|
||||
entity.object:setvelocity(vec_backward)
|
||||
entity.object:setacceleration(acc_backward)
|
||||
--entity.object:setvelocity(vec_backward)
|
||||
--entity.object:setacceleration(acc_backward)
|
||||
elseif not ctrl.down or ctrl.up then
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
entity.object:setvelocity(vec_stop)
|
||||
@ -372,17 +393,23 @@ function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, moving_a
|
||||
entity.object:setvelocity({x=velo.x*decell, y=0, z=velo.z*decell})
|
||||
end
|
||||
if ctrl.sneak and shoots and entity.loaded then
|
||||
local pname = entity.driver:get_player_name();
|
||||
local inv = minetest.get_inventory({type="player", name=pname});
|
||||
if inv:contains_item("main", arrow.."_item") then
|
||||
local remov = inv:remove_item("main", arrow.."_item")
|
||||
entity.loaded = false
|
||||
local pos = entity.object:getpos()
|
||||
local obj = minetest.env:add_entity({x=pos.x+0+dir.x*2,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2}, arrow)
|
||||
local vec = {x=dir.x*9,y=dir.y*9,z=dir.z*9}
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
obj:setyaw(yaw+math.pi/2)
|
||||
obj:setvelocity(vec)
|
||||
local object = obj:get_luaentity()
|
||||
object.launcher = entity.driver
|
||||
minetest.after(1, function()
|
||||
minetest.after(reload, function()
|
||||
entity.loaded = true
|
||||
end)
|
||||
end
|
||||
end
|
||||
--lib_mount animation
|
||||
if minetest.get_modpath("mobs")then
|
||||
@ -399,25 +426,33 @@ function object_fly(entity, dtime, speed, accel, decell, shoots, arrow, moving_a
|
||||
end
|
||||
|
||||
--flying with jump to increase height in addition to looking up/down
|
||||
function object_fly_2(entity, dtime, speed, accel, decell, shoots, arrow, moving_anim, stand_anim)
|
||||
function object_fly_2(entity, dtime, speed, accel, decell, shoots, arrow, reload, moving_anim, stand_anim)
|
||||
local ctrl = entity.driver:get_player_control()
|
||||
local dir = entity.driver:get_look_dir();
|
||||
local yvel = entity.object:getvelocity().y
|
||||
local vec_forward = {x=dir.x*speed,y=yvel,z=dir.z*speed}
|
||||
local acc_forward = {x=dir.x*accel/2,y=yvel,z=dir.z*accel/2}
|
||||
local vec_backward = {x=-dir.x*speed,y=yvel,z=-dir.z*speed}
|
||||
local acc_backward = {x=dir.x*accel/2,y=yvel,z=dir.z*accel/2}
|
||||
--local vec_backward = {x=-dir.x*speed,y=yvel,z=-dir.z*speed}
|
||||
--local acc_backward = {x=dir.x*accel/2,y=yvel,z=dir.z*accel/2}
|
||||
local vec_stop = {x=entity.object:getvelocity().x*decell, y=entity.object:getvelocity().y, z=entity.object:getvelocity().z*decell}
|
||||
local vec_rise = {x=entity.object:getvelocity().x, y=speed*accel, z=entity.object:getvelocity().z}
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
if ctrl.up then
|
||||
|
||||
|
||||
|
||||
--water effects
|
||||
local pos = entity.object:getpos()
|
||||
local node = minetest.get_node(pos).name
|
||||
if node == "default:water_source" or node == "default:river_water_source" or node == "default:river_water_flowing" or node == "default:water_flowing" then
|
||||
entity.object:setvelocity({x=velo.x*0.9, y=-1, z=velo.z*0.9})
|
||||
elseif ctrl.up then
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
entity.object:setvelocity(vec_forward)
|
||||
entity.object:setacceleration(acc_forward)
|
||||
elseif ctrl.down then
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
entity.object:setvelocity(vec_backward)
|
||||
entity.object:setacceleration(acc_backward)
|
||||
--elseif ctrl.down then
|
||||
-- entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
-- entity.object:setvelocity(vec_backward)
|
||||
-- entity.object:setacceleration(acc_backward)
|
||||
elseif ctrl.jump then
|
||||
entity.object:setyaw(yaw+math.pi+math.pi/2)
|
||||
entity.object:setvelocity(vec_rise)
|
||||
@ -427,6 +462,10 @@ function object_fly_2(entity, dtime, speed, accel, decell, shoots, arrow, moving
|
||||
entity.object:setacceleration({x=0, y=-4.5, z=0})
|
||||
end
|
||||
if ctrl.sneak and shoots and entity.loaded then
|
||||
local pname = entity.driver:get_player_name();
|
||||
local inv = minetest.get_inventory({type="player", name=pname});
|
||||
if inv:contains_item("main", arrow.."_item") then
|
||||
local remov = inv:remove_item("main", arrow.."_item")
|
||||
entity.loaded = false
|
||||
local pos = entity.object:getpos()
|
||||
local obj = minetest.env:add_entity({x=pos.x+0+dir.x*2,y=pos.y+1.5+dir.y,z=pos.z+0+dir.z*2}, arrow)
|
||||
@ -434,9 +473,12 @@ function object_fly_2(entity, dtime, speed, accel, decell, shoots, arrow, moving
|
||||
local yaw = entity.driver:get_look_yaw();
|
||||
obj:setyaw(yaw+math.pi/2)
|
||||
obj:setvelocity(vec)
|
||||
minetest.after(1, function()
|
||||
local object = obj:get_luaentity()
|
||||
object.launcher = entity.driver
|
||||
minetest.after(reload, function()
|
||||
entity.loaded = true
|
||||
end)
|
||||
end
|
||||
end
|
||||
--lib_mount animation
|
||||
local velo = entity.object:getvelocity()
|
||||
@ -486,17 +528,17 @@ function object_glide(entity, dtime, speed, decell, gravity, moving_anim, stand_
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--lib_mount animation
|
||||
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||
if stand_anim and stand_anim ~= nilthen then
|
||||
set_animation(entity, stand_anim)
|
||||
end
|
||||
return
|
||||
end
|
||||
if moving_anim and moving_anim ~= nil then
|
||||
set_animation(entity, moving_anim)
|
||||
end
|
||||
-- if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||
-- if stand_anim and stand_anim ~= nilthen then
|
||||
-- set_animation(entity, stand_anim)
|
||||
-- end
|
||||
-- return
|
||||
-- end
|
||||
-- if moving_anim and moving_anim ~= nil then
|
||||
-- set_animation(entity, moving_anim)
|
||||
-- end
|
||||
end
|
||||
|
||||
--lib_mount (not required by new functions)
|
||||
@ -670,7 +712,7 @@ minetest.register_tool(vehicle.."_spawner", {
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
on_use = function(item, placer, pointed_thing)
|
||||
on_place = function(item, placer, pointed_thing)
|
||||
local dir = placer:get_look_dir();
|
||||
local playerpos = placer:getpos();
|
||||
if pointed_thing.type == "node" and not is_boat then
|
||||
@ -679,7 +721,7 @@ minetest.register_tool(vehicle.."_spawner", {
|
||||
object.owner = placer
|
||||
item:take_item()
|
||||
return item
|
||||
elseif pointed_thing.type == "node" and minetest.get_item_group(pointed_thing.name, "water")then
|
||||
elseif pointed_thing.type == "node" and minetest.get_item_group(pointed_thing.name, "water") then
|
||||
local obj = minetest.env:add_entity(pointed_thing.under, vehicle)
|
||||
local object = obj:get_luaentity()
|
||||
object.owner = placer
|
||||
@ -690,6 +732,45 @@ minetest.register_tool(vehicle.."_spawner", {
|
||||
})
|
||||
end
|
||||
|
||||
--explodinate
|
||||
|
||||
function explode(ent, radius)
|
||||
local pos = ent.object:getpos()
|
||||
minetest.add_particlespawner({
|
||||
amount = 90,
|
||||
time = 4,
|
||||
minpos = {x=pos.x-0.6, y=pos.y, z=pos.z-0.6},
|
||||
maxpos = {x=pos.x+0.6, y=pos.y+1, z=pos.z+0.6},
|
||||
minvel = {x=-0.1, y=3.5, z=-0.1},
|
||||
maxvel = {x=0.1, y=4.5, z=0.1},
|
||||
minacc = {x=-1.3, y=-0.7, z=-1.3},
|
||||
maxacc = {x=1.3, y=-0.7, z=1.3},
|
||||
minexptime = 2,
|
||||
maxexptime = 3,
|
||||
minsize = 15,
|
||||
maxsize = 25,
|
||||
collisiondetection = false,
|
||||
texture = "vehicles_explosion.png"
|
||||
})
|
||||
minetest.after(1, function()
|
||||
minetest.add_particlespawner({
|
||||
amount = 30,
|
||||
time = 4,
|
||||
minpos = {x=pos.x-1, y=pos.y+2, z=pos.z-1},
|
||||
maxpos = {x=pos.x+1, y=pos.y+3, z=pos.z+1},
|
||||
minvel = {x=0, y=-1, z=0},
|
||||
maxvel = {x=0, y=-2, z=0},
|
||||
minacc = {x=0, y=-0.6, z=0},
|
||||
maxacc = {x=0, y=-0.6, z=0},
|
||||
minexptime = 1,
|
||||
maxexptime = 3,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
texture = "vehicles_explosion.png"
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
--out of date, left behind in case it is needed again
|
||||
function vehicle_drop(ent, player, name)
|
||||
|
@ -1,3 +1,5 @@
|
||||
default
|
||||
tnt
|
||||
mobs?
|
||||
dye
|
||||
mobs?
|
||||
stairs?
|
720
init.lua
@ -16,7 +16,7 @@ dofile(minetest.get_modpath("vehicles").."/api.lua")
|
||||
-- end
|
||||
-- end)
|
||||
|
||||
local step = 1.2
|
||||
local step = 1.1
|
||||
|
||||
minetest.register_entity("vehicles:missile", {
|
||||
visual = "mesh",
|
||||
@ -76,11 +76,16 @@ minetest.register_entity("vehicles:missile", {
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("vehicles:miss", {
|
||||
minetest.register_craftitem("vehicles:missile_2_item", {
|
||||
description = "Missile",
|
||||
inventory_image = "vehicles_missile_inv.png"
|
||||
})
|
||||
|
||||
minetest.register_craftitem("vehicles:bullet_item", {
|
||||
description = "Bullet",
|
||||
inventory_image = "vehicles_bullet_inv.png"
|
||||
})
|
||||
|
||||
|
||||
minetest.register_entity("vehicles:missile_2", {
|
||||
visual = "mesh",
|
||||
@ -233,7 +238,18 @@ minetest.register_entity("vehicles:tank", {
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
destroy(self, puncher, "vehicles:tank")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
@ -263,7 +279,18 @@ minetest.register_entity("vehicles:turret", {
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:turret")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
self.object:setvelocity({x=0, y=-1, z=0})
|
||||
@ -296,7 +323,18 @@ minetest.register_entity("vehicles:firetruck", {
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:firetruck")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
@ -323,17 +361,34 @@ minetest.register_entity("vehicles:ute", {
|
||||
if self.driver and clicker == self.driver then
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif self.driver and clicker ~= self.driver and not self.rider then
|
||||
clicker:set_attach(self.object, "", {x=0, y=5, z=-5}, {x=0, y=0, z=0})
|
||||
clicker:set_attach(self.object, "", {x=0, y=5, z=-5}, false, {x=0, y=0, z=-2})
|
||||
self.rider = true
|
||||
elseif self.driver and clicker ~=self.driver and self.rider then
|
||||
clicker:set_detach()
|
||||
self.rider = false
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:ute")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -387,10 +442,27 @@ minetest.register_entity("vehicles:ute2", {
|
||||
self.rider = false
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:ute2")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -421,10 +493,27 @@ minetest.register_entity("vehicles:astonmaaton", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:astonmaaton")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -455,10 +544,27 @@ minetest.register_entity("vehicles:nizzan", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:nizzan")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -506,13 +612,30 @@ minetest.register_entity("vehicles:nizzan2", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:nizzan2")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
@ -557,10 +680,27 @@ minetest.register_entity("vehicles:lambogoni", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:lambogoni")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -591,10 +731,27 @@ minetest.register_entity("vehicles:lambogoni2", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:lambogoni2")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -625,10 +782,27 @@ minetest.register_entity("vehicles:masda", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:masda")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -659,13 +833,30 @@ minetest.register_entity("vehicles:musting", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:musting")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
@ -693,10 +884,27 @@ minetest.register_entity("vehicles:musting2", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:musting2")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -737,11 +945,28 @@ minetest.register_entity("vehicles:fewawi", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:fewawi")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -782,11 +1007,28 @@ minetest.register_entity("vehicles:fewawi2", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:fewawi2")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -817,13 +1059,30 @@ minetest.register_entity("vehicles:pooshe", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:pooshe")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
@ -851,10 +1110,27 @@ minetest.register_entity("vehicles:pooshe2", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:pooshe2")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
@ -885,13 +1161,30 @@ minetest.register_entity("vehicles:masda2", {
|
||||
object_detach(self, clicker, {x=1, y=0, z=1})
|
||||
elseif not self.driver then
|
||||
object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4})
|
||||
minetest.sound_play("engine_start",
|
||||
{gain = 6, max_hear_distance = 3, loop = false})
|
||||
self.sound_ready = false
|
||||
minetest.after(14, function()
|
||||
self.sound_ready = true
|
||||
end)
|
||||
end
|
||||
end,
|
||||
on_activate = function(self)
|
||||
self.nitro = true
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:masda2")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
@ -922,7 +1215,18 @@ minetest.register_entity("vehicles:boat", {
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:boat")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
@ -958,13 +1262,25 @@ minetest.register_entity("vehicles:jet", {
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:jet")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.driver then
|
||||
object_fly(self, dtime, 14, 0.2, 0.95, true, "vehicles:missile_2", 1, {x=1, y=1}, {x=10, y=10})
|
||||
return false
|
||||
end
|
||||
self.object:setvelocity({x=0, y=-1, z=0})
|
||||
return true
|
||||
end,
|
||||
})
|
||||
@ -989,14 +1305,25 @@ minetest.register_entity("vehicles:plane", {
|
||||
end
|
||||
end,
|
||||
on_punch = function(self, puncher)
|
||||
vehicle_drop(self, puncher, "vehicles:plane")
|
||||
if not self.driver then
|
||||
local name = self.object:get_luaentity().name
|
||||
local pos = self.object:getpos()
|
||||
minetest.env:add_item(pos, name.."_spawner")
|
||||
self.object:remove()
|
||||
end
|
||||
if self.object:get_hp() == 0 then
|
||||
if self.driver then
|
||||
object_detach(self, self.driver, {x=1, y=0, z=1})
|
||||
end
|
||||
explode(self, 5)
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.anim and not self.driver then
|
||||
self.object:set_animation({x=1, y=1}, 5, 0)
|
||||
end
|
||||
if self.driver then
|
||||
object_fly(self, dtime, 10, 0.1, 0.95, false, nil, nil, nil)
|
||||
object_fly(self, dtime, 10, 0.1, 0.95, false, nil, nil, nil, nil)
|
||||
if not self.anim then
|
||||
self.object:set_animation({x=1, y=9}, 20, 0)
|
||||
self.anim = true
|
||||
@ -1150,8 +1477,8 @@ minetest.register_tool("vehicles:rc", {
|
||||
local playerpos = placer:getpos();
|
||||
local pname = placer:get_player_name();
|
||||
local inv = minetest.get_inventory({type="player", name=pname});
|
||||
if inv:contains_item("main", "vehicles:miss") then
|
||||
local remov = inv:remove_item("main", "vehicles:miss")
|
||||
if inv:contains_item("main", "vehicles:missile_2_item") then
|
||||
local remov = inv:remove_item("main", "vehicles:missile_2_item")
|
||||
local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1+dir.y,z=playerpos.z+0+dir.z}, "vehicles:missile")
|
||||
local vec = {x=dir.x*6,y=dir.y*6,z=dir.z*6}
|
||||
obj:setvelocity(vec)
|
||||
@ -1160,8 +1487,331 @@ minetest.register_tool("vehicles:rc", {
|
||||
end,
|
||||
})
|
||||
|
||||
--crafting recipes and materials
|
||||
|
||||
minetest.register_craftitem("vehicles:wheel", {
|
||||
description = "Wheel",
|
||||
inventory_image = "vehicles_wheel.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("vehicles:engine", {
|
||||
description = "Engine",
|
||||
inventory_image = "vehicles_engine.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("vehicles:body", {
|
||||
description = "Car Body",
|
||||
inventory_image = "vehicles_car_body.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("vehicles:armor", {
|
||||
description = "Armor plating",
|
||||
inventory_image = "vehicles_armor.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("vehicles:gun", {
|
||||
description = "Vehicle Gun",
|
||||
inventory_image = "vehicles_gun.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("vehicles:propeller", {
|
||||
description = "Propeller",
|
||||
inventory_image = "vehicles_propeller.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("vehicles:jet_engine", {
|
||||
description = "Jet Engine",
|
||||
inventory_image = "vehicles_jet_engine.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:propeller",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "", ""},
|
||||
{"", "group:stick", ""},
|
||||
{"", "", "default:steel_ingot"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:jet_engine",
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot", "vehicles:propeller", "default:steel_ingot"},
|
||||
{"", "default:steel_ingot", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:armor",
|
||||
recipe = {
|
||||
{"", "default:gold_lump", ""},
|
||||
{"", "default:iron_lump", ""},
|
||||
{"", "default:copper_lump", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:gun",
|
||||
recipe = {
|
||||
{"", "vehicles:armor", ""},
|
||||
{"vehicles:armor", "default:coal_lump", "vehicles:armor"},
|
||||
{"", "default:steel_ingot", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:wheel",
|
||||
recipe = {
|
||||
{"", "default:coal_lump", ""},
|
||||
{"default:coal_lump", "default:steel_ingot", "default:coal_lump"},
|
||||
{"", "default:coal_lump", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:engine",
|
||||
recipe = {
|
||||
{"default:copper_ingot", "", "default:copper_ingot"},
|
||||
{"default:steel_ingot", "default:mese_crystal", "default:steel_ingot"},
|
||||
{"", "default:steel_ingot", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:body",
|
||||
recipe = {
|
||||
{"", "default:glass", ""},
|
||||
{"default:glass", "default:steel_ingot", "default:glass"},
|
||||
{"", "", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:bullet_item 5",
|
||||
recipe = {
|
||||
{"default:coal_lump", "default:iron_lump",},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:missile_2_item",
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"", "default:torch", ""},
|
||||
{"default:stick", "default:coal_lump", "default:stick"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:masda_spawner",
|
||||
recipe = {
|
||||
{"", "dye:magenta", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:masda2_spawner",
|
||||
recipe = {
|
||||
{"", "dye:orange", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:ute_spawner",
|
||||
recipe = {
|
||||
{"", "dye:brown", ""},
|
||||
{"default:steel_ingot", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:ute2_spawner",
|
||||
recipe = {
|
||||
{"", "dye:white", ""},
|
||||
{"default:steel_ingot", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:nizzan2_spawner",
|
||||
recipe = {
|
||||
{"", "dye:green", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:nizzan_spawner",
|
||||
recipe = {
|
||||
{"", "dye:brown", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:astonmaaton_spawner",
|
||||
recipe = {
|
||||
{"", "dye:white", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:pooshe_spawner",
|
||||
recipe = {
|
||||
{"", "dye:red", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:pooshe2_spawner",
|
||||
recipe = {
|
||||
{"", "dye:yellow", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:lambogoni_spawner",
|
||||
recipe = {
|
||||
{"", "dye:grey", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:lambogoni2_spawner",
|
||||
recipe = {
|
||||
{"", "dye:yellow", ""},
|
||||
{"", "vehicles:body", "dye:grey"},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:fewawi_spawner",
|
||||
recipe = {
|
||||
{"", "dye:red", ""},
|
||||
{"", "vehicles:body", "default:glass"},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:fewawi2_spawner",
|
||||
recipe = {
|
||||
{"", "dye:blue", ""},
|
||||
{"", "vehicles:body", "default:glass"},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:musting_spawner",
|
||||
recipe = {
|
||||
{"", "dye:violet", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:musting2_spawner",
|
||||
recipe = {
|
||||
{"", "dye:blue", ""},
|
||||
{"", "vehicles:body", ""},
|
||||
{"vehicles:wheel", "vehicles:engine", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:tank_spawner",
|
||||
recipe = {
|
||||
{"", "vehicles:gun", ""},
|
||||
{"vehicles:armor", "vehicles:engine", "vehicles:armor"},
|
||||
{"vehicles:wheel", "vehicles:wheel", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:turret_spawner",
|
||||
recipe = {
|
||||
{"", "vehicles:gun", ""},
|
||||
{"vehicles:armor", "vehicles:engine", "vehicles:armor"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:jet_spawner",
|
||||
recipe = {
|
||||
{"", "vehicles:gun", ""},
|
||||
{"vehicles:jet_engine", "default:steel_ingot", "vehicles:jet_engine"},
|
||||
{"", "default:steel_ingot", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:plane_spawner",
|
||||
recipe = {
|
||||
{"", "vehicles:propeller", ""},
|
||||
{"default:steel_ingot", "vehicles:engine", "default:steel_ingot"},
|
||||
{"", "default:steel_ingot", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:boat_spawner",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"default:steel_ingot", "vehicles:engine", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:firetruck_spawner",
|
||||
recipe = {
|
||||
{"", "dye:red", ""},
|
||||
{"vehicles:body", "vehicles:engine", "vehicles:body"},
|
||||
{"vehicles:wheel", "default:steel_ingot", "vehicles:wheel"}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vehicles:backpack",
|
||||
recipe = {
|
||||
{"group:grass", "group:grass", "group:grass"},
|
||||
{"group:stick", "", "group:stick"},
|
||||
{"", "group:wood", ""}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--decorative nodes
|
||||
|
||||
if minetest.setting_get("vehicles_nodes") == nil then
|
||||
minetest.setting_set("vehicles_nodes", "true")
|
||||
end
|
||||
|
||||
if minetest.setting_get("vehicles_nodes") then
|
||||
function vehicles.register_simplenode(name, desc, texture, light)
|
||||
minetest.register_node("vehicles:"..name, {
|
||||
description = desc,
|
||||
@ -1169,6 +1819,7 @@ minetest.register_node("vehicles:"..name, {
|
||||
groups = {cracky=1},
|
||||
paramtype2 = "facedir",
|
||||
light_source = light,
|
||||
default.node_sound_stone_defaults(),
|
||||
})
|
||||
end
|
||||
|
||||
@ -1183,14 +1834,23 @@ vehicles.register_simplenode("stripe3", "Road surface (white stripes)", "vehicle
|
||||
vehicles.register_simplenode("stripe4", "Road surface (yellow stripes)", "vehicles_road_stripe4.png", 0)
|
||||
vehicles.register_simplenode("window", "Building glass", "vehicles_window.png", 0)
|
||||
vehicles.register_simplenode("stripes", "Hazard stipes", "vehicles_stripes.png", 10)
|
||||
vehicles.register_simplenode("lights", "Tunnel lights", "vehicles_lights.png", 20)
|
||||
|
||||
minetest.register_node("vehicles:lights", {
|
||||
description = "Tunnel Lights",
|
||||
tiles = {"vehicles_lights_top.png", "vehicles_lights_top.png", "vehicles_lights.png", "vehicles_lights.png", "vehicles_lights.png", "vehicles_lights.png"},
|
||||
groups = {cracky=1},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 20,
|
||||
})
|
||||
|
||||
if minetest.get_modpath("stairs") then
|
||||
stairs.register_stair_and_slab("road_surface", "vehicles:road",
|
||||
{cracky = 1},
|
||||
{"vehicles_road.png"},
|
||||
"Road Surface Stair",
|
||||
"Road Surface Slab",
|
||||
default.node_sound_stone_defaults())
|
||||
end
|
||||
|
||||
minetest.register_node("vehicles:neon_arrow", {
|
||||
description = "neon arrows (left)",
|
||||
@ -1467,8 +2127,8 @@ minetest.register_node("vehicles:tyres", {
|
||||
{-0.4375, -0.4375, -0.5, 0.4375, -0.0625, 0.5}, -- NodeBox5
|
||||
}
|
||||
},
|
||||
groups = {cracky=1},
|
||||
groups = {cracky=1, falling_node=1},
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -24,6 +24,9 @@ License for Textures, Models
|
||||
|
||||
CC BY-SA 3.0 UNPORTED. Created by D00Med
|
||||
|
||||
License for sounds:
|
||||
CC BY-NC 3.0 oniwe https://freesound.org/people/oniwe/sounds/32316/
|
||||
|
||||
--License of lib_mount:
|
||||
-- Minetest mod: lib_mount
|
||||
-- =======================
|
||||
|
BIN
sounds/engine.ogg
Normal file
BIN
sounds/engine_start.ogg
Normal file
BIN
textures/vehicles_armor.png
Normal file
After Width: | Height: | Size: 380 B |
BIN
textures/vehicles_bullet_inv.png
Normal file
After Width: | Height: | Size: 251 B |
BIN
textures/vehicles_car_body.png
Normal file
After Width: | Height: | Size: 385 B |
BIN
textures/vehicles_engine.png
Normal file
After Width: | Height: | Size: 591 B |
BIN
textures/vehicles_explosion.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
textures/vehicles_gun.png
Normal file
After Width: | Height: | Size: 259 B |
BIN
textures/vehicles_jet_engine.png
Normal file
After Width: | Height: | Size: 285 B |
BIN
textures/vehicles_lights_top.png
Normal file
After Width: | Height: | Size: 313 B |
BIN
textures/vehicles_propeller.png
Normal file
After Width: | Height: | Size: 153 B |
BIN
textures/vehicles_speed_0.png
Normal file
After Width: | Height: | Size: 301 B |
BIN
textures/vehicles_speed_1.png
Normal file
After Width: | Height: | Size: 289 B |
BIN
textures/vehicles_speed_10.png
Normal file
After Width: | Height: | Size: 290 B |
BIN
textures/vehicles_speed_2.png
Normal file
After Width: | Height: | Size: 276 B |
BIN
textures/vehicles_speed_3.png
Normal file
After Width: | Height: | Size: 247 B |
BIN
textures/vehicles_speed_4.png
Normal file
After Width: | Height: | Size: 299 B |
BIN
textures/vehicles_speed_5.png
Normal file
After Width: | Height: | Size: 305 B |
BIN
textures/vehicles_speed_6.png
Normal file
After Width: | Height: | Size: 301 B |
BIN
textures/vehicles_speed_7.png
Normal file
After Width: | Height: | Size: 298 B |
BIN
textures/vehicles_speed_8.png
Normal file
After Width: | Height: | Size: 280 B |
BIN
textures/vehicles_speed_9.png
Normal file
After Width: | Height: | Size: 279 B |
BIN
textures/vehicles_wheel.png
Normal file
After Width: | Height: | Size: 368 B |