mirror of
https://github.com/APercy/automobiles_pck
synced 2025-08-27 07:06:23 +02:00
ragtop
This commit is contained in:
parent
b1b698fc66
commit
0be087e26e
@ -18,6 +18,7 @@ dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "fuel_management.lua"
|
|||||||
dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "ground_detection.lua")
|
dofile(minetest.get_modpath("automobiles") .. DIR_DELIM .. "ground_detection.lua")
|
||||||
dofile(minetest.get_modpath("automobiles_roadster") .. DIR_DELIM .. "roadster_utilities.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_forms.lua")
|
||||||
|
|
||||||
|
|
||||||
-- --minetest.add_entity(e_pos, "automobiles_roadster:target")
|
-- --minetest.add_entity(e_pos, "automobiles_roadster:target")
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -163,7 +163,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
initial_properties = {
|
initial_properties = {
|
||||||
physical = true,
|
physical = true,
|
||||||
collide_with_objects = true,
|
collide_with_objects = true,
|
||||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 2, 0.5},
|
collisionbox = {-0.5, -0.5, -0.5, 0.5, 1, 0.5},
|
||||||
selectionbox = {-1.5, 0.0, -1.5, 1.5, 2, 1.5},
|
selectionbox = {-1.5, 0.0, -1.5, 1.5, 2, 1.5},
|
||||||
stepheight = 0.5,
|
stepheight = 0.5,
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
@ -181,10 +181,10 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
"automobiles_roadster_fuel.png", --combustivel
|
"automobiles_roadster_fuel.png", --combustivel
|
||||||
"automobiles_metal2.png", --parabrisa fixo
|
"automobiles_metal2.png", --parabrisa fixo
|
||||||
"automobiles_alpha.png", --vidro do parabrisa fixo
|
"automobiles_alpha.png", --vidro do parabrisa fixo
|
||||||
"automobiles_metal2.png", --parabrisa movel
|
|
||||||
"automobiles_alpha.png", --vidro do parabrisa movel
|
|
||||||
"automobiles_painting.png", --portas
|
"automobiles_painting.png", --portas
|
||||||
"automobiles_black.png", --portas interno
|
"automobiles_black.png", --portas interno
|
||||||
|
"automobiles_metal2.png", --parabrisa movel
|
||||||
|
"automobiles_alpha.png", --vidro do parabrisa movel
|
||||||
"automobiles_black.png", --paralamas
|
"automobiles_black.png", --paralamas
|
||||||
"automobiles_metal2.png", --carenagem do radiador
|
"automobiles_metal2.png", --carenagem do radiador
|
||||||
"automobiles_painting.png", --tanque de combustivel
|
"automobiles_painting.png", --tanque de combustivel
|
||||||
@ -215,6 +215,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
_roll = math.rad(0),
|
_roll = math.rad(0),
|
||||||
_pitch = math.rad(90),
|
_pitch = math.rad(90),
|
||||||
_longit_speed = 0,
|
_longit_speed = 0,
|
||||||
|
_show_rag = true,
|
||||||
|
|
||||||
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
get_staticdata = function(self) -- unloaded/unloads ... is now saved
|
||||||
return minetest.serialize({
|
return minetest.serialize({
|
||||||
@ -227,6 +228,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
stored_last_checkpoint = self._last_checkpoint,
|
stored_last_checkpoint = self._last_checkpoint,
|
||||||
stored_total_laps = self._total_laps,
|
stored_total_laps = self._total_laps,
|
||||||
stored_race_id = self._race_id,
|
stored_race_id = self._race_id,
|
||||||
|
stored_rag = self._show_rag,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -243,6 +245,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
self._last_checkpoint = data.stored_last_checkpoint
|
self._last_checkpoint = data.stored_last_checkpoint
|
||||||
self._total_laps = data.stored_total_laps
|
self._total_laps = data.stored_total_laps
|
||||||
self._race_id = data.stored_race_id
|
self._race_id = data.stored_race_id
|
||||||
|
self._show_rag = data.stored_rag
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:set_animation({x = 1, y = 8}, 0, 0, true)
|
self.object:set_animation({x = 1, y = 8}, 0, 0, true)
|
||||||
@ -254,6 +257,11 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
top1:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
top1:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||||
self.top1 = top1
|
self.top1 = top1
|
||||||
|
|
||||||
|
local top2=minetest.add_entity(self.object:get_pos(),'automobiles_roadster:top2')
|
||||||
|
top2:set_attach(self.object,'',{x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||||
|
self.top2 = top2
|
||||||
|
self.top2:set_properties({is_visible=false})
|
||||||
|
|
||||||
local front_suspension=minetest.add_entity(self.object:get_pos(),'automobiles_roadster:front_suspension')
|
local front_suspension=minetest.add_entity(self.object:get_pos(),'automobiles_roadster:front_suspension')
|
||||||
front_suspension:set_attach(self.object,'',{x=0,y=0,z=24.22},{x=0,y=0,z=0})
|
front_suspension:set_attach(self.object,'',{x=0,y=0,z=24.22},{x=0,y=0,z=0})
|
||||||
self.front_suspension = front_suspension
|
self.front_suspension = front_suspension
|
||||||
@ -336,6 +344,16 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
|
|
||||||
local accel = vector.add(longit_drag,later_drag)
|
local accel = vector.add(longit_drag,later_drag)
|
||||||
|
|
||||||
|
if self._show_rag == true then
|
||||||
|
self.object:set_bone_position("parabrisa", {x=0, y=15.8317, z=15.0394}, {x=0, y=0, z=0})
|
||||||
|
self.top2:set_properties({is_visible=true})
|
||||||
|
self.top1:set_properties({is_visible=false})
|
||||||
|
else
|
||||||
|
self.object:set_bone_position("parabrisa", {x=0, y=15.8317, z=15.0394}, {x=math.rad(-145), y=0, z=0})
|
||||||
|
self.top2:set_properties({is_visible=false})
|
||||||
|
self.top1:set_properties({is_visible=true})
|
||||||
|
end
|
||||||
|
|
||||||
local player = nil
|
local player = nil
|
||||||
local is_attached = false
|
local is_attached = false
|
||||||
if self.driver_name then
|
if self.driver_name then
|
||||||
@ -584,6 +602,8 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
if name == self.driver_name then
|
if name == self.driver_name then
|
||||||
|
roadster.driver_formspec(name)
|
||||||
|
--[[
|
||||||
--detach all
|
--detach all
|
||||||
automobiles.dettach_driver(self, clicker)
|
automobiles.dettach_driver(self, clicker)
|
||||||
-- sound
|
-- sound
|
||||||
@ -599,7 +619,7 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.object:set_acceleration(vector.multiply(automobiles.vector_up, -automobiles.gravity))
|
self.object:set_acceleration(vector.multiply(automobiles.vector_up, -automobiles.gravity))
|
||||||
|
]]--
|
||||||
else
|
else
|
||||||
if name == self.owner then
|
if name == self.owner then
|
||||||
--is the owner, okay, lets attach
|
--is the owner, okay, lets attach
|
||||||
|
50
automobiles_roadster/roadster_forms.lua
Normal file
50
automobiles_roadster/roadster_forms.lua
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
--------------
|
||||||
|
-- Manual --
|
||||||
|
--------------
|
||||||
|
|
||||||
|
function roadster.getCarFromPlayer(player)
|
||||||
|
local seat = player:get_attach()
|
||||||
|
if seat then
|
||||||
|
local car = seat:get_attach()
|
||||||
|
return car
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function roadster.driver_formspec(name)
|
||||||
|
local basic_form = table.concat({
|
||||||
|
"formspec_version[3]",
|
||||||
|
"size[6,4.5]",
|
||||||
|
}, "")
|
||||||
|
|
||||||
|
basic_form = basic_form.."button[1,1.0;4,1;go_out;Go Offboard]"
|
||||||
|
basic_form = basic_form.."button[1,2.5;4,1;top;Close/Open Ragtop]"
|
||||||
|
|
||||||
|
minetest.show_formspec(name, "roadster:driver_main", basic_form)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if formname == "roadster:driver_main" then
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local car_obj = roadster.getCarFromPlayer(player)
|
||||||
|
local ent = car_obj:get_luaentity()
|
||||||
|
if fields.top then
|
||||||
|
if ent._show_rag == true then
|
||||||
|
ent._show_rag = false
|
||||||
|
else
|
||||||
|
ent._show_rag = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if fields.go_out then
|
||||||
|
|
||||||
|
if ent._passenger then --any pax?
|
||||||
|
local pax_obj = minetest.get_player_by_name(ent._passenger)
|
||||||
|
automobiles.dettach_pax(ent, pax_obj)
|
||||||
|
end
|
||||||
|
|
||||||
|
automobiles.dettach_driver(ent, player)
|
||||||
|
end
|
||||||
|
minetest.close_formspec(name, "roadster:driver_main")
|
||||||
|
end
|
||||||
|
end)
|
Loading…
Reference in New Issue
Block a user