mirror of
https://github.com/SmallJoker/boost_cart.git
synced 2024-11-23 23:23:44 +01:00
Adjust 3rd person eye height
This commit is contained in:
parent
6e01bf2bf9
commit
307b5d1f92
@ -6,6 +6,25 @@ function boost_cart:get_sign(z)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function boost_cart:manage_attachment(player, status, obj)
|
||||||
|
if not player then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
if default.player_attached[player_name] == status then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
default.player_attached[player_name] = status
|
||||||
|
|
||||||
|
if status then
|
||||||
|
player:set_attach(obj, "", {x=0, y=6, z=0}, {x=0, y=0, z=0})
|
||||||
|
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
||||||
|
else
|
||||||
|
player:set_detach()
|
||||||
|
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function boost_cart:velocity_to_dir(v)
|
function boost_cart:velocity_to_dir(v)
|
||||||
if math.abs(v.x) > math.abs(v.z) then
|
if math.abs(v.x) > math.abs(v.z) then
|
||||||
return {x=boost_cart:get_sign(v.x), y=boost_cart:get_sign(v.y), z=0}
|
return {x=boost_cart:get_sign(v.x), y=boost_cart:get_sign(v.y), z=0}
|
||||||
|
10
init.lua
10
init.lua
@ -55,11 +55,10 @@ function boost_cart.cart:on_rightclick(clicker)
|
|||||||
local player_name = clicker:get_player_name()
|
local player_name = clicker:get_player_name()
|
||||||
if self.driver and player_name == self.driver then
|
if self.driver and player_name == self.driver then
|
||||||
self.driver = nil
|
self.driver = nil
|
||||||
clicker:set_detach()
|
boost_cart:manage_attachment(clicker, false)
|
||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
self.driver = player_name
|
self.driver = player_name
|
||||||
default.player_attached[player_name] = true
|
boost_cart:manage_attachment(clicker, true, self.object)
|
||||||
clicker:set_attach(self.object, "", {x=0, y=3, z=0}, {x=0, y=0, z=0})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -90,11 +89,8 @@ function boost_cart.cart:on_punch(puncher, time_from_last_punch, tool_capabiliti
|
|||||||
if self.old_pos then
|
if self.old_pos then
|
||||||
self.object:setpos(self.old_pos)
|
self.object:setpos(self.old_pos)
|
||||||
end
|
end
|
||||||
default.player_attached[self.driver] = nil
|
|
||||||
local player = minetest.get_player_by_name(self.driver)
|
local player = minetest.get_player_by_name(self.driver)
|
||||||
if player then
|
boost_cart:manage_attachment(player, false)
|
||||||
player:set_detach()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
for _,obj_ in ipairs(self.attached_items) do
|
for _,obj_ in ipairs(self.attached_items) do
|
||||||
if obj_ then
|
if obj_ then
|
||||||
|
Loading…
Reference in New Issue
Block a user