mirror of
https://github.com/APercy/automobiles_pck
synced 2025-06-16 13:58:01 +02:00
change destruction mode for the cars
This commit is contained in:
parent
ae0cb68139
commit
77db8e0d00
@ -11,24 +11,29 @@ minetest.register_craftitem("automobiles_beetle:beetle_body",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- beetle
|
-- beetle
|
||||||
minetest.register_craftitem("automobiles_beetle:beetle", {
|
minetest.register_tool("automobiles_beetle:beetle", {
|
||||||
description = S("Beetle"),
|
description = "Beetle",
|
||||||
inventory_image = "automobiles_beetle.png",
|
inventory_image = "automobiles_beetle.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_beetle:beetle")
|
local car = minetest.add_entity(pointed_pos, "automobiles_beetle:beetle", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
|
ent.hp = 50 --reset hp
|
||||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
@ -16,24 +16,29 @@ minetest.register_craftitem("automobiles_buggy:wheel",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- buggy
|
-- buggy
|
||||||
minetest.register_craftitem("automobiles_buggy:buggy", {
|
minetest.register_tool("automobiles_buggy:buggy", {
|
||||||
description = S("Buggy"),
|
description = S("Buggy"),
|
||||||
inventory_image = "automobiles_buggy.png",
|
inventory_image = "automobiles_buggy.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_buggy:buggy")
|
local car = minetest.add_entity(pointed_pos, "automobiles_buggy:buggy", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
|
ent.hp = 50 --reset hp
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||||
|
@ -235,7 +235,6 @@ minetest.register_entity("automobiles_buggy:buggy", {
|
|||||||
_engine_sound = "buggy_engine",
|
_engine_sound = "buggy_engine",
|
||||||
_max_fuel = 10,
|
_max_fuel = 10,
|
||||||
_formspec_function = buggy.driver_formspec,
|
_formspec_function = buggy.driver_formspec,
|
||||||
_destroy_function = buggy.destroy,
|
|
||||||
|
|
||||||
_vehicle_name = "Buggy",
|
_vehicle_name = "Buggy",
|
||||||
_drive_wheel_pos = {x=-4.26,y=6.01,z=16},
|
_drive_wheel_pos = {x=-4.26,y=6.01,z=16},
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
--dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_global_definitions.lua")
|
|
||||||
--dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_hud.lua")
|
|
||||||
|
|
||||||
-- destroy the buggy
|
|
||||||
function buggy.destroy(self, puncher)
|
|
||||||
automobiles_lib.remove_light(self)
|
|
||||||
if self.sound_handle then
|
|
||||||
minetest.sound_stop(self.sound_handle)
|
|
||||||
self.sound_handle = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.driver_name then
|
|
||||||
-- detach the driver first (puncher must be driver)
|
|
||||||
if puncher then
|
|
||||||
puncher:set_detach()
|
|
||||||
puncher:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
|
||||||
if minetest.global_exists("player_api") then
|
|
||||||
player_api.player_attached[self.driver_name] = nil
|
|
||||||
-- player should stand again
|
|
||||||
player_api.set_animation(puncher, "stand")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.driver_name = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
if self.rag then self.rag:remove() end
|
|
||||||
if self.front_suspension then self.front_suspension:remove() end
|
|
||||||
if self.lf_wheel then self.lf_wheel:remove() end
|
|
||||||
if self.rf_wheel then self.rf_wheel:remove() end
|
|
||||||
if self.rear_suspension then self.rear_suspension:remove() end
|
|
||||||
if self.lr_wheel then self.lr_wheel:remove() end
|
|
||||||
if self.rr_wheel then self.rr_wheel:remove() end
|
|
||||||
if self.steering then self.steering:remove() end
|
|
||||||
if self.steering_axis then self.steering_axis:remove() end
|
|
||||||
if self.driver_seat then self.driver_seat:remove() end
|
|
||||||
if self.passenger_seat then self.passenger_seat:remove() end
|
|
||||||
if self.fuel_gauge then self.fuel_gauge:remove() end
|
|
||||||
if self.lights then self.lights:remove() end
|
|
||||||
if self.r_lights then self.r_lights:remove() end
|
|
||||||
|
|
||||||
automobiles_lib.destroy_inventory(self)
|
|
||||||
self.object:remove()
|
|
||||||
|
|
||||||
pos.y=pos.y+2
|
|
||||||
|
|
||||||
--minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_buggy:buggy')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_buggy:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_buggy:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_buggy:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_buggy:wheel')
|
|
||||||
end
|
|
||||||
|
|
@ -21,7 +21,6 @@ dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua")
|
|||||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "fuel_management.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 .. "ground_detection.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_forms.lua")
|
dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_forms.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_utilities.lua")
|
|
||||||
dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_entities.lua")
|
dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_entities.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_crafts.lua")
|
dofile(minetest.get_modpath("automobiles_buggy") .. DIR_DELIM .. "buggy_crafts.lua")
|
||||||
|
|
||||||
|
@ -11,25 +11,30 @@ minetest.register_craftitem("automobiles_catrelle:catrelle_body",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- catrelle
|
-- catrelle
|
||||||
minetest.register_craftitem("automobiles_catrelle:catrelle", {
|
minetest.register_tool("automobiles_catrelle:catrelle", {
|
||||||
description = S("Catrelle"),
|
description = S("Catrelle"),
|
||||||
inventory_image = "automobiles_catrelle.png",
|
inventory_image = "automobiles_catrelle.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_catrelle:catrelle")
|
local car = minetest.add_entity(pointed_pos, "automobiles_catrelle:catrelle", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
ent._catrelle_type = 0
|
ent.hp = 50 --reset hp
|
||||||
|
ent._catrelle_type = ent._catrelle_type or 0
|
||||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
@ -44,25 +49,30 @@ minetest.register_craftitem("automobiles_catrelle:catrelle", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- catrelle TL
|
-- catrelle TL
|
||||||
minetest.register_craftitem("automobiles_catrelle:catrelle_4f", {
|
minetest.register_tool("automobiles_catrelle:catrelle_4f", {
|
||||||
description = S("Catrelle 4F"),
|
description = S("Catrelle 4F"),
|
||||||
inventory_image = "automobiles_catrelle.png",
|
inventory_image = "automobiles_catrelle.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_catrelle:catrelle_4f")
|
local car = minetest.add_entity(pointed_pos, "automobiles_catrelle:catrelle_4f", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
ent._catrelle_type = 1
|
ent.hp = 50 --reset hp
|
||||||
|
ent._catrelle_type = ent._catrelle_type or 1
|
||||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
@ -5,57 +5,6 @@ function catrelle.extra_parts(self)
|
|||||||
self.back_seat = back_seat
|
self.back_seat = back_seat
|
||||||
end
|
end
|
||||||
|
|
||||||
-- destroy the delorean
|
|
||||||
function catrelle.destroy(self, puncher)
|
|
||||||
automobiles_lib.remove_light(self)
|
|
||||||
if self.sound_handle then
|
|
||||||
minetest.sound_stop(self.sound_handle)
|
|
||||||
self.sound_handle = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.driver_name then
|
|
||||||
-- detach the driver first (puncher must be driver)
|
|
||||||
if puncher then
|
|
||||||
puncher:set_detach()
|
|
||||||
puncher:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
|
||||||
if minetest.global_exists("player_api") then
|
|
||||||
player_api.player_attached[self.driver_name] = nil
|
|
||||||
-- player should stand again
|
|
||||||
player_api.set_animation(puncher, "stand")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.driver_name = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
if self.front_suspension then self.front_suspension:remove() end
|
|
||||||
if self.lf_wheel then self.lf_wheel:remove() end
|
|
||||||
if self.rf_wheel then self.rf_wheel:remove() end
|
|
||||||
if self.rear_suspension then self.rear_suspension:remove() end
|
|
||||||
if self.lr_wheel then self.lr_wheel:remove() end
|
|
||||||
if self.rr_wheel then self.rr_wheel:remove() end
|
|
||||||
if self.fuel_gauge then self.fuel_gauge:remove() end
|
|
||||||
if self.lights then self.lights:remove() end
|
|
||||||
if self.r_lights then self.r_lights:remove() end
|
|
||||||
if self.reverse_lights then self.reverse_lights:remove() end
|
|
||||||
if self.turn_l_light then self.turn_l_light:remove() end
|
|
||||||
if self.turn_r_light then self.turn_r_light:remove() end
|
|
||||||
if self.back_seat then self.back_seat:remove() end
|
|
||||||
|
|
||||||
automobiles_lib.seats_destroy(self)
|
|
||||||
|
|
||||||
automobiles_lib.destroy_inventory(self)
|
|
||||||
self.object:remove()
|
|
||||||
|
|
||||||
pos.y=pos.y+2
|
|
||||||
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
|
||||||
end
|
|
||||||
--
|
--
|
||||||
-- entity
|
-- entity
|
||||||
--
|
--
|
||||||
@ -381,7 +330,6 @@ catrelle.car_properties2._seat_pos = {{x=-4.0,y=3,z=15},{x=4.0,y=3,z=15}, {x=-4.
|
|||||||
catrelle.car_properties2._color = "#0063b0"
|
catrelle.car_properties2._color = "#0063b0"
|
||||||
catrelle.car_properties2._trunk_slots = 16
|
catrelle.car_properties2._trunk_slots = 16
|
||||||
catrelle.car_properties2._extra_items_function = catrelle.extra_parts
|
catrelle.car_properties2._extra_items_function = catrelle.extra_parts
|
||||||
catrelle.car_properties2._destroy_function = catrelle.destroy
|
|
||||||
|
|
||||||
minetest.register_entity("automobiles_catrelle:catrelle_4f", catrelle.car_properties2)
|
minetest.register_entity("automobiles_catrelle:catrelle_4f", catrelle.car_properties2)
|
||||||
|
|
||||||
|
@ -11,24 +11,29 @@ minetest.register_craftitem("automobiles_coupe:coupe_body",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- coupe
|
-- coupe
|
||||||
minetest.register_craftitem("automobiles_coupe:coupe", {
|
minetest.register_tool("automobiles_coupe:coupe", {
|
||||||
description = S("Coupe"),
|
description = S("Coupe"),
|
||||||
inventory_image = "automobiles_coupe.png",
|
inventory_image = "automobiles_coupe.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_coupe:coupe")
|
local car = minetest.add_entity(pointed_pos, "automobiles_coupe:coupe", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
|
ent.hp = 50 --reset hp
|
||||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
@ -11,25 +11,30 @@ minetest.register_craftitem("automobiles_delorean:delorean_body",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- delorean
|
-- delorean
|
||||||
minetest.register_craftitem("automobiles_delorean:delorean", {
|
minetest.register_tool("automobiles_delorean:delorean", {
|
||||||
description = S("Delorean"),
|
description = S("Delorean"),
|
||||||
inventory_image = "automobiles_delorean.png",
|
inventory_image = "automobiles_delorean.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_delorean:delorean")
|
local car = minetest.add_entity(pointed_pos, "automobiles_delorean:delorean", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
ent._car_type = 0
|
ent.hp = 50 --reset hp
|
||||||
|
ent._car_type = ent._car_type or 0
|
||||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
@ -44,25 +49,30 @@ minetest.register_craftitem("automobiles_delorean:delorean", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- delorean
|
-- delorean
|
||||||
minetest.register_craftitem("automobiles_delorean:time_machine", {
|
minetest.register_tool("automobiles_delorean:time_machine", {
|
||||||
description = S("Time Machine"),
|
description = S("Time Machine"),
|
||||||
inventory_image = "automobiles_delorean.png",
|
inventory_image = "automobiles_delorean.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_delorean:delorean")
|
local car = minetest.add_entity(pointed_pos, "automobiles_delorean:delorean", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
ent._car_type = 1
|
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("delorean: " .. ent._car_type)
|
||||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
|
@ -401,14 +401,13 @@ minetest.register_entity("automobiles_delorean:delorean", {
|
|||||||
_inv_id = "",
|
_inv_id = "",
|
||||||
_change_color = automobiles_lib.paint,
|
_change_color = automobiles_lib.paint,
|
||||||
_intensity = 4,
|
_intensity = 4,
|
||||||
_car_type = 0,
|
_car_type = nil,
|
||||||
_car_gravity = -automobiles_lib.gravity,
|
_car_gravity = -automobiles_lib.gravity,
|
||||||
_is_flying = 0,
|
_is_flying = 0,
|
||||||
_trunk_slots = 8,
|
_trunk_slots = 8,
|
||||||
_engine_sound = "delorean_engine",
|
_engine_sound = "delorean_engine",
|
||||||
_max_fuel = 10,
|
_max_fuel = 10,
|
||||||
_formspec_function = delorean.driver_formspec,
|
_formspec_function = delorean.driver_formspec,
|
||||||
_destroy_function = delorean.destroy,
|
|
||||||
|
|
||||||
_vehicle_name = S("Delorean"),
|
_vehicle_name = S("Delorean"),
|
||||||
_drive_wheel_pos = {x=-4.66, y=6.31, z=15.69},
|
_drive_wheel_pos = {x=-4.66, y=6.31, z=15.69},
|
||||||
|
@ -23,7 +23,6 @@ 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 .. "forms.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "control.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 .. "flight.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "utilities.lua")
|
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "entities.lua")
|
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "entities.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "crafts.lua")
|
dofile(minetest.get_modpath("automobiles_delorean") .. DIR_DELIM .. "crafts.lua")
|
||||||
|
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
-- destroy the delorean
|
|
||||||
function delorean.destroy(self, puncher)
|
|
||||||
automobiles_lib.remove_light(self)
|
|
||||||
if self.sound_handle then
|
|
||||||
minetest.sound_stop(self.sound_handle)
|
|
||||||
self.sound_handle = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.driver_name then
|
|
||||||
-- detach the driver first (puncher must be driver)
|
|
||||||
if puncher then
|
|
||||||
puncher:set_detach()
|
|
||||||
puncher:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
|
||||||
if minetest.global_exists("player_api") then
|
|
||||||
player_api.player_attached[self.driver_name] = nil
|
|
||||||
-- player should stand again
|
|
||||||
player_api.set_animation(puncher, "stand")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.driver_name = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
if self.front_suspension then self.front_suspension:remove() end
|
|
||||||
if self.lf_wheel then self.lf_wheel:remove() end
|
|
||||||
if self.rf_wheel then self.rf_wheel:remove() end
|
|
||||||
if self.rear_suspension then self.rear_suspension:remove() end
|
|
||||||
if self.lr_wheel then self.lr_wheel:remove() end
|
|
||||||
if self.rr_wheel then self.rr_wheel:remove() end
|
|
||||||
if self.driver_seat then self.driver_seat:remove() end
|
|
||||||
if self.passenger_seat then self.passenger_seat:remove() end
|
|
||||||
if self.fuel_gauge then self.fuel_gauge:remove() end
|
|
||||||
if self.lights then self.lights:remove() end
|
|
||||||
if self.r_lights then self.r_lights:remove() end
|
|
||||||
if self.reverse_lights then self.reverse_lights:remove() end
|
|
||||||
if self.normal_kit then self.normal_kit:remove() end
|
|
||||||
if self.instruments then self.instruments:remove() end
|
|
||||||
if self.turn_l_light then self.turn_l_light:remove() end
|
|
||||||
if self.turn_r_light then self.turn_r_light:remove() end
|
|
||||||
|
|
||||||
automobiles_lib.destroy_inventory(self)
|
|
||||||
self.object:remove()
|
|
||||||
|
|
||||||
pos.y=pos.y+2
|
|
||||||
|
|
||||||
--minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_delorean:delorean')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
|
||||||
end
|
|
||||||
|
|
@ -24,6 +24,7 @@ automobiles_lib.fuel = {['biofuel:biofuel'] = 1,['biofuel:bottle_fuel'] = 1,
|
|||||||
automobiles_lib.gravity = 9.8
|
automobiles_lib.gravity = 9.8
|
||||||
automobiles_lib.ideal_step = 0.2
|
automobiles_lib.ideal_step = 0.2
|
||||||
automobiles_lib.is_creative = minetest.settings:get_bool("creative_mode", false)
|
automobiles_lib.is_creative = minetest.settings:get_bool("creative_mode", false)
|
||||||
|
automobiles_lib.can_collect_car = minetest.settings:get_bool("collect_automobiles", false)
|
||||||
|
|
||||||
automobiles_lib.is_drift_game = false
|
automobiles_lib.is_drift_game = false
|
||||||
automobiles_lib.extra_drift = false
|
automobiles_lib.extra_drift = false
|
||||||
@ -505,19 +506,49 @@ function automobiles_lib.destroy(self, puncher)
|
|||||||
if self.reverse_lights then self.reverse_lights:remove() end
|
if self.reverse_lights then self.reverse_lights:remove() end
|
||||||
if self.turn_l_light then self.turn_l_light:remove() end
|
if self.turn_l_light then self.turn_l_light:remove() end
|
||||||
if self.turn_r_light then self.turn_r_light:remove() end
|
if self.turn_r_light then self.turn_r_light:remove() end
|
||||||
|
if self.rag then self.rag:remove() end --for buggy
|
||||||
|
if self.back_seat then self.back_seat:remove() end --for catrelle
|
||||||
|
if self.instruments then self.instruments:remove() end --for delorean
|
||||||
|
if self.normal_kit then self.normal_kit:remove() end
|
||||||
|
if self.rag_rect then self.rag_rect:remove() end --for roadster
|
||||||
|
|
||||||
|
|
||||||
automobiles_lib.seats_destroy(self)
|
automobiles_lib.seats_destroy(self)
|
||||||
|
|
||||||
automobiles_lib.destroy_inventory(self)
|
automobiles_lib.destroy_inventory(self)
|
||||||
self.object:remove()
|
|
||||||
|
|
||||||
pos.y=pos.y+2
|
pos.y=pos.y+2
|
||||||
|
|
||||||
|
if automobiles_lib.can_collect_car == false then
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:wheel')
|
||||||
|
else
|
||||||
|
local lua_ent = self.object:get_luaentity()
|
||||||
|
local staticdata = lua_ent:get_staticdata(self)
|
||||||
|
local obj_name = lua_ent.name
|
||||||
|
local player = minetest.get_player_by_name(self.owner)
|
||||||
|
|
||||||
|
local stack = ItemStack(obj_name)
|
||||||
|
local stack_meta = stack:get_meta()
|
||||||
|
stack_meta:set_string("staticdata", staticdata)
|
||||||
|
|
||||||
|
if player then
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
if inv then
|
||||||
|
if inv:room_for_item("main", stack) then
|
||||||
|
inv:add_item("main", stack)
|
||||||
|
else
|
||||||
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5}, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5}, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.object:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
function automobiles_lib.engine_set_sound_and_animation(self, _longit_speed)
|
function automobiles_lib.engine_set_sound_and_animation(self, _longit_speed)
|
||||||
|
5
automobiles_lib/settingtypes.txt
Normal file
5
automobiles_lib/settingtypes.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# all settings for client menu or in minetest.conf on servers
|
||||||
|
|
||||||
|
|
||||||
|
# make cars collectable
|
||||||
|
collect_automobiles (Collect vehicles to inventory) bool true
|
@ -15,24 +15,29 @@ minetest.register_craftitem("automobiles_motorcycle:wheel",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- motorcycle
|
-- motorcycle
|
||||||
minetest.register_craftitem("automobiles_motorcycle:motorcycle", {
|
minetest.register_tool("automobiles_motorcycle:motorcycle", {
|
||||||
description = S("Motorcycle"),
|
description = S("Motorcycle"),
|
||||||
inventory_image = "automobiles_motorcycle.png",
|
inventory_image = "automobiles_motorcycle.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_motorcycle:motorcycle")
|
local car = minetest.add_entity(pointed_pos, "automobiles_motorcycle:motorcycle", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
|
ent.hp = 50 --reset hp
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||||
|
@ -33,13 +33,38 @@ function motorcycle.destroy(self, puncher)
|
|||||||
if self.pax_mesh then self.pax_mesh:remove() end
|
if self.pax_mesh then self.pax_mesh:remove() end
|
||||||
|
|
||||||
automobiles_lib.destroy_inventory(self)
|
automobiles_lib.destroy_inventory(self)
|
||||||
self.object:remove()
|
|
||||||
|
|
||||||
pos.y=pos.y+2
|
pos.y=pos.y+2
|
||||||
|
|
||||||
|
if automobiles_lib.can_collect_car == false then
|
||||||
--minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_motorcycle:motorcycle')
|
--minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_motorcycle:motorcycle')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_motorcycle:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_motorcycle:wheel')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_motorcycle:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_motorcycle:wheel')
|
||||||
|
else
|
||||||
|
local lua_ent = self.object:get_luaentity()
|
||||||
|
local staticdata = lua_ent:get_staticdata(self)
|
||||||
|
local obj_name = lua_ent.name
|
||||||
|
local player = minetest.get_player_by_name(self.owner)
|
||||||
|
|
||||||
|
local stack = ItemStack(obj_name)
|
||||||
|
local stack_meta = stack:get_meta()
|
||||||
|
stack_meta:set_string("staticdata", staticdata)
|
||||||
|
|
||||||
|
if player then
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
if inv then
|
||||||
|
if inv:room_for_item("main", stack) then
|
||||||
|
inv:add_item("main", stack)
|
||||||
|
else
|
||||||
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5}, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5}, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.object:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "control.lua")
|
|||||||
dofile(minetest.get_modpath("automobiles_lib") .. DIR_DELIM .. "fuel_management.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 .. "ground_detection.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_forms.lua")
|
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_forms.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_utilities.lua")
|
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_entities.lua")
|
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_entities.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_crafts.lua")
|
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_crafts.lua")
|
||||||
|
|
||||||
|
@ -16,24 +16,29 @@ minetest.register_craftitem("automobiles_roadster:wheel",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- roadster
|
-- roadster
|
||||||
minetest.register_craftitem("automobiles_roadster:roadster", {
|
minetest.register_tool("automobiles_roadster:roadster", {
|
||||||
description = S("Roadster"),
|
description = S("Roadster"),
|
||||||
inventory_image = "automobiles_roadster.png",
|
inventory_image = "automobiles_roadster.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_roadster:roadster")
|
local car = minetest.add_entity(pointed_pos, "automobiles_roadster:roadster", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
|
ent.hp = 50 --reset hp
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
--dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_global_definitions.lua")
|
|
||||||
--dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_hud.lua")
|
|
||||||
|
|
||||||
-- destroy the roadster
|
|
||||||
function roadster.destroy(self, puncher)
|
|
||||||
automobiles_lib.remove_light(self)
|
|
||||||
if self.sound_handle then
|
|
||||||
minetest.sound_stop(self.sound_handle)
|
|
||||||
self.sound_handle = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.driver_name then
|
|
||||||
-- detach the driver first (puncher must be driver)
|
|
||||||
if puncher then
|
|
||||||
puncher:set_detach()
|
|
||||||
puncher:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
|
||||||
if minetest.global_exists("player_api") then
|
|
||||||
player_api.player_attached[self.driver_name] = nil
|
|
||||||
-- player should stand again
|
|
||||||
player_api.set_animation(puncher, "stand")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.driver_name = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
if self.rag_rect then self.rag_rect:remove() end
|
|
||||||
if self.rag then self.rag:remove() end
|
|
||||||
if self.front_suspension then self.front_suspension:remove() end
|
|
||||||
if self.lf_wheel then self.lf_wheel:remove() end
|
|
||||||
if self.rf_wheel then self.rf_wheel:remove() end
|
|
||||||
if self.rear_suspension then self.rear_suspension:remove() end
|
|
||||||
if self.lr_wheel then self.lr_wheel:remove() end
|
|
||||||
if self.rr_wheel then self.rr_wheel:remove() end
|
|
||||||
if self.steering then self.steering:remove() end
|
|
||||||
if self.steering_axis then self.steering_axis:remove() end
|
|
||||||
if self.driver_seat then self.driver_seat:remove() end
|
|
||||||
if self.passenger_seat then self.passenger_seat:remove() end
|
|
||||||
if self.fuel_gauge then self.fuel_gauge:remove() end
|
|
||||||
if self.lights then self.lights:remove() end
|
|
||||||
|
|
||||||
automobiles_lib.destroy_inventory(self)
|
|
||||||
self.object:remove()
|
|
||||||
|
|
||||||
pos.y=pos.y+2
|
|
||||||
|
|
||||||
--minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_roadster:roadster')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_roadster:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_roadster:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_roadster:wheel')
|
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_roadster:wheel')
|
|
||||||
end
|
|
||||||
|
|
@ -11,24 +11,29 @@ minetest.register_craftitem("automobiles_trans_am:trans_am_body",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- trans_am
|
-- trans_am
|
||||||
minetest.register_craftitem("automobiles_trans_am:trans_am", {
|
minetest.register_tool("automobiles_trans_am:trans_am", {
|
||||||
description = S("Trans Am"),
|
description = S("Trans Am"),
|
||||||
inventory_image = "automobiles_trans_am.png",
|
inventory_image = "automobiles_trans_am.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_trans_am:trans_am")
|
local car = minetest.add_entity(pointed_pos, "automobiles_trans_am:trans_am", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
|
ent.hp = 50 --reset hp
|
||||||
ent._trans_am_type = 0
|
ent._trans_am_type = 0
|
||||||
--minetest.chat_send_all("owner: " .. ent.owner)
|
--minetest.chat_send_all("owner: " .. ent.owner)
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
|
@ -16,24 +16,29 @@ minetest.register_craftitem("automobiles_vespa:wheel",{
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- vespa
|
-- vespa
|
||||||
minetest.register_craftitem("automobiles_vespa:vespa", {
|
minetest.register_tool("automobiles_vespa:vespa", {
|
||||||
description = S("Vespa"),
|
description = S("Vespa"),
|
||||||
inventory_image = "automobiles_vespa.png",
|
inventory_image = "automobiles_vespa.png",
|
||||||
liquids_pointable = false,
|
liquids_pointable = false,
|
||||||
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local stack_meta = itemstack:get_meta()
|
||||||
|
local staticdata = stack_meta:get_string("staticdata")
|
||||||
|
|
||||||
local pointed_pos = pointed_thing.above
|
local pointed_pos = pointed_thing.above
|
||||||
--pointed_pos.y=pointed_pos.y+0.2
|
--pointed_pos.y=pointed_pos.y+0.2
|
||||||
local car = minetest.add_entity(pointed_pos, "automobiles_vespa:vespa")
|
local car = minetest.add_entity(pointed_pos, "automobiles_vespa:vespa", staticdata)
|
||||||
if car and placer then
|
if car and placer then
|
||||||
local ent = car:get_luaentity()
|
local ent = car:get_luaentity()
|
||||||
local owner = placer:get_player_name()
|
local owner = placer:get_player_name()
|
||||||
if ent then
|
if ent then
|
||||||
ent.owner = owner
|
ent.owner = owner
|
||||||
|
ent.hp = 50 --reset hp
|
||||||
car:set_yaw(placer:get_look_horizontal())
|
car:set_yaw(placer:get_look_horizontal())
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
|
||||||
|
@ -33,13 +33,38 @@ function vespa.destroy(self, puncher)
|
|||||||
if self.pax_mesh then self.pax_mesh:remove() end
|
if self.pax_mesh then self.pax_mesh:remove() end
|
||||||
|
|
||||||
automobiles_lib.destroy_inventory(self)
|
automobiles_lib.destroy_inventory(self)
|
||||||
self.object:remove()
|
|
||||||
|
|
||||||
pos.y=pos.y+2
|
pos.y=pos.y+2
|
||||||
|
|
||||||
|
if automobiles_lib.can_collect_car == false then
|
||||||
--minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_vespa:vespa')
|
--minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_vespa:vespa')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_lib:engine')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_vespa:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_vespa:wheel')
|
||||||
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_vespa:wheel')
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5},'automobiles_vespa:wheel')
|
||||||
|
else
|
||||||
|
local lua_ent = self.object:get_luaentity()
|
||||||
|
local staticdata = lua_ent:get_staticdata(self)
|
||||||
|
local obj_name = lua_ent.name
|
||||||
|
local player = minetest.get_player_by_name(self.owner)
|
||||||
|
|
||||||
|
local stack = ItemStack(obj_name)
|
||||||
|
local stack_meta = stack:get_meta()
|
||||||
|
stack_meta:set_string("staticdata", staticdata)
|
||||||
|
|
||||||
|
if player then
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
if inv then
|
||||||
|
if inv:room_for_item("main", stack) then
|
||||||
|
inv:add_item("main", stack)
|
||||||
|
else
|
||||||
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5}, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
minetest.add_item({x=pos.x+math.random()-0.5,y=pos.y,z=pos.z+math.random()-0.5}, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.object:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user