mirror of
https://github.com/SmallJoker/boost_cart.git
synced 2024-11-30 18:13:44 +01:00
Various improvements and bugfixes
Clear driver on leave using the detach callback (0.5.x and later) Fix upright_sprite attachment position Fallback to the regular node sound when metal does not exist Set animation to "stand" on attach
This commit is contained in:
parent
3781f6d4c0
commit
c6b9e4b672
@ -54,6 +54,12 @@ function cart_entity:on_rightclick(clicker)
|
|||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
self.driver = player_name
|
self.driver = player_name
|
||||||
boost_cart:manage_attachment(clicker, self.object)
|
boost_cart:manage_attachment(clicker, self.object)
|
||||||
|
|
||||||
|
if default.player_set_animation then
|
||||||
|
-- player_api(/default) does not update the animation
|
||||||
|
-- when the player is attached, reset to default animation
|
||||||
|
default.player_set_animation(clicker, "stand")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -81,6 +87,13 @@ function cart_entity:get_staticdata()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- 0.5.x and later: When the driver leaves
|
||||||
|
function cart_entity:on_detach_child(child)
|
||||||
|
if child and child:get_player_name() == self.driver then
|
||||||
|
self.driver = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local vel = self.object:get_velocity()
|
local vel = self.object:get_velocity()
|
||||||
|
@ -19,6 +19,9 @@ function boost_cart:manage_attachment(player, obj)
|
|||||||
|
|
||||||
if status then
|
if status then
|
||||||
local y_pos = self.old_player_model and 6 or -4
|
local y_pos = self.old_player_model and 6 or -4
|
||||||
|
if player:get_properties().visual == "upright_sprite" then
|
||||||
|
y_pos = -4
|
||||||
|
end
|
||||||
player:set_attach(obj, "", {x=0, y=y_pos, z=0}, {x=0, y=0, z=0})
|
player:set_attach(obj, "", {x=0, y=y_pos, z=0}, {x=0, y=0, z=0})
|
||||||
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
||||||
else
|
else
|
||||||
@ -208,6 +211,9 @@ function boost_cart:boost_rail(pos, amount)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function boost_cart:register_rail(name, def_overwrite)
|
function boost_cart:register_rail(name, def_overwrite)
|
||||||
|
local sound_func = default.node_sound_metal_defaults
|
||||||
|
or default.node_sound_defaults
|
||||||
|
|
||||||
local def = {
|
local def = {
|
||||||
drawtype = "raillike",
|
drawtype = "raillike",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -218,7 +224,7 @@ function boost_cart:register_rail(name, def_overwrite)
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||||
},
|
},
|
||||||
sounds = default.node_sound_metal_defaults()
|
sounds = sound_func()
|
||||||
}
|
}
|
||||||
for k, v in pairs(def_overwrite) do
|
for k, v in pairs(def_overwrite) do
|
||||||
def[k] = v
|
def[k] = v
|
||||||
|
2
init.lua
2
init.lua
@ -25,7 +25,7 @@ if not default.player_attached then
|
|||||||
default.player_attached = {}
|
default.player_attached = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(0.5, function()
|
minetest.after(0, function()
|
||||||
boost_cart.old_player_model = not minetest.global_exists("player_api")
|
boost_cart.old_player_model = not minetest.global_exists("player_api")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user