forked from APercy/ju52
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentities.lua
119 lines (104 loc) · 3.49 KB
/
entities.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
--
-- entity
--
ju52.vector_up = vector.new(0, 1, 0)
minetest.register_entity('ju52:wheels',{
initial_properties = {
physical = false,
collide_with_objects=false,
pointable=false,
visual = "mesh",
backface_culling = false,
mesh = "ju52_wheels.b3d",
textures = {
"airutils_metal.png", --suporte bequilha
ju52.skin_texture, --suporte trem
"airutils_black.png", --pneu bequilha
"airutils_metal.png", --roda bequilha
"airutils_black.png", --pneu trem
"airutils_metal.png", --roda trem
},
},
on_activate = function(self,std)
self.sdata = minetest.deserialize(std) or {}
if self.sdata.remove then self.object:remove() end
end,
get_staticdata=function(self)
self.sdata.remove=true
return minetest.serialize(self.sdata)
end,
})
minetest.register_entity('ju52:cabin_interactor',{
initial_properties = {
physical = true,
collide_with_objects=true,
collisionbox = {-1, 0, -1, 1, 3, 1},
visual = "mesh",
mesh = "airutils_seat_base.b3d",
textures = {"airutils_alpha.png",},
},
dist_moved = 0,
max_hp = 65535,
on_activate = function(self,std)
self.sdata = minetest.deserialize(std) or {}
if self.sdata.remove then self.object:remove() end
end,
get_staticdata=function(self)
self.sdata.remove=true
return minetest.serialize(self.sdata)
end,
on_punch = function(self, puncher, ttime, toolcaps, dir, damage)
--minetest.chat_send_all("punch")
if not puncher or not puncher:is_player() then
return
end
end,
on_rightclick = function(self, clicker)
local name = clicker:get_player_name()
local parent_obj = self.object:get_attach()
if not parent_obj then return end
local parent_self = parent_obj:get_luaentity()
local copilot_name = nil
if parent_self.co_pilot and parent_self._have_copilot then
copilot_name = parent_self.co_pilot
end
if name == parent_self.driver_name then
local itmstck=clicker:get_wielded_item()
local item_name = ""
if itmstck then item_name = itmstck:get_name() end
--adf program function
if (item_name == "compassgps:cgpsmap_marked") then
local meta = minetest.deserialize(itmstck:get_metadata())
if meta then
parent_self._adf_destiny = {x=meta["x"], z=meta["z"]}
end
else
--formspec of the plane
if not parent_self._custom_pilot_formspec then
airutils.pilot_formspec(name)
else
parent_self._custom_pilot_formspec(name)
end
airutils.sit(clicker)
end
--=========================
-- detach copilot
--=========================
elseif name == copilot_name then
if parent_self._command_is_given then
--open the plane menu for the copilot
--formspec of the plane
if not parent_self._custom_pilot_formspec then
airutils.pilot_formspec(name)
else
parent_self._custom_pilot_formspec(name)
end
else
airutils.pax_formspec(name)
end
end
end,
})
minetest.register_entity('ju52:ju52',
airutils.properties_copy(ju52.plane_properties)
)