added plane ejection

This commit is contained in:
Alexsandro Percy 2023-08-26 17:49:53 -03:00
parent c33b0c2a4b
commit df4da519b3
2 changed files with 33 additions and 0 deletions

View file

@ -508,3 +508,35 @@ minetest.register_chatcommand("transfer_ownership", {
end
end
})
minetest.register_chatcommand("eject_from_plane", {
params = "",
description = "Ejects from a plane",
privs = {interact = true},
func = function(name, param)
local colorstring = core.colorize('#ff0000', " >>> you are not inside a plane")
local player = minetest.get_player_by_name(name)
local attached_to = player:get_attach()
if attached_to ~= nil then
local seat = attached_to:get_attach()
if seat ~= nil then
local entity = seat:get_luaentity()
if entity then
if entity.on_step == airutils.on_step then
if entity.driver_name == name then
airutils.dettachPlayer(entity, player)
elseif entity._passenger == name then
local passenger = minetest.get_player_by_name(entity._passenger)
airutils.dettach_pax(entity, passenger)
end
else
minetest.chat_send_player(name,colorstring)
end
end
end
else
minetest.chat_send_player(name,colorstring)
end
end
})

View file

@ -24,3 +24,4 @@ local function fetch_setting(name)
return settings and settings:get(sname) or minetest.settings:get(sname)
end