mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 18:41:21 +00:00
improved ADF messages and added first support for mineclone
This commit is contained in:
parent
877f922145
commit
f058f30be2
4 changed files with 99 additions and 45 deletions
5
init.lua
5
init.lua
|
@ -40,7 +40,7 @@ dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "light.lua")
|
||||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "physics_lib.lua")
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "physics_lib.lua")
|
||||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "init.lua")
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "lib_planes" .. DIR_DELIM .. "init.lua")
|
||||||
|
|
||||||
if player_api and not minetest.settings:get_bool('airutils.disable_uniforms') then
|
if minetest.get_modpath("player_api") and not minetest.settings:get_bool('airutils.disable_uniforms') then
|
||||||
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "pilot_skin_manager.lua")
|
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "pilot_skin_manager.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ function airutils.detect_player_api(player)
|
||||||
local player_proterties = player:get_properties()
|
local player_proterties = player:get_properties()
|
||||||
--local mesh = "character.b3d"
|
--local mesh = "character.b3d"
|
||||||
--if player_proterties.mesh == mesh then
|
--if player_proterties.mesh == mesh then
|
||||||
|
if minetest.get_modpath("player_api") then
|
||||||
local models = player_api.registered_models
|
local models = player_api.registered_models
|
||||||
local character = models[player_proterties.mesh]
|
local character = models[player_proterties.mesh]
|
||||||
--minetest.chat_send_all(dump(character));
|
--minetest.chat_send_all(dump(character));
|
||||||
|
@ -140,7 +141,7 @@ function airutils.detect_player_api(player)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--end
|
end
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,60 +1,72 @@
|
||||||
local storage = minetest.get_mod_storage()
|
local storage = minetest.get_mod_storage()
|
||||||
airutils.modname = minetest.get_current_modname()
|
airutils.modname = minetest.get_current_modname()
|
||||||
|
|
||||||
|
--function to format formspec for mineclone. In case of minetest, just returns an empty string
|
||||||
|
local function get_itemslot_bg(a, b, c, d)
|
||||||
|
if not minetest.get_modpath("player_api") then
|
||||||
|
return mcl_formspec.get_itemslot_bg(a,b,c,d)
|
||||||
|
end
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
local function get_formspec_by_size(self, size)
|
local function get_formspec_by_size(self, size)
|
||||||
local background = default.gui_bg .. default.gui_bg_img .. default.gui_slots
|
local background = ""
|
||||||
|
local hotbar = ""
|
||||||
|
local is_minetest_game = minetest.get_modpath("player_api") or false
|
||||||
|
if is_minetest_game then
|
||||||
|
background = background .. default.gui_bg .. default.gui_bg_img .. default.gui_slots
|
||||||
|
hotbar = default.get_hotbar_bg(0,4.85)
|
||||||
|
end
|
||||||
local default_inventory_formspecs = {
|
local default_inventory_formspecs = {
|
||||||
["2"]="size[8,6]".. background ..
|
["2"]="size[8,6]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;3.0,0;3,1;]" ..
|
"list[detached:" .. self._inv_id .. ";main;3.0,0;3,1;]" .. get_itemslot_bg(3.0, 0, 2, 1) ..
|
||||||
"list[current_player;main;0,2;8,4;]" ..
|
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
|
|
||||||
["3"]="size[8,6]".. background ..
|
["3"]="size[8,6]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;2.5,0;3,1;]" ..
|
"list[detached:" .. self._inv_id .. ";main;2.5,0;3,1;]" .. get_itemslot_bg(2.5, 0, 3, 1) ..
|
||||||
"list[current_player;main;0,2;8,4;]" ..
|
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
|
|
||||||
["4"]="size[8,6]".. background ..
|
["4"]="size[8,6]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;2,0;4,1;]" ..
|
"list[detached:" .. self._inv_id .. ";main;2,0;4,1;]" .. get_itemslot_bg(2.0, 0, 4, 1) ..
|
||||||
"list[current_player;main;0,2;8,4;]" ..
|
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
|
|
||||||
["6"]="size[8,6]".. background ..
|
["6"]="size[8,6]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;1,0;6,1;]"..
|
"list[detached:" .. self._inv_id .. ";main;1,0;6,1;]".. get_itemslot_bg(1.0, 0, 6, 1) ..
|
||||||
"list[current_player;main;0,2;8,4;]" ..
|
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
|
|
||||||
["8"]="size[8,6]".. background ..
|
["8"]="size[8,6]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,1;]"..
|
"list[detached:" .. self._inv_id .. ";main;0,0;8,1;]".. get_itemslot_bg(0, 0, 8, 1) ..
|
||||||
"list[current_player;main;0,2;8,4;]" ..
|
"list[current_player;main;0,2;8,4;]" .. get_itemslot_bg(0, 2, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
|
|
||||||
["12"]="size[8,7]".. background ..
|
["12"]="size[8,7]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;1,0;6,2;]"..
|
"list[detached:" .. self._inv_id .. ";main;1,0;6,2;]".. get_itemslot_bg(1, 0, 6, 2) ..
|
||||||
"list[current_player;main;0,3;8,4;]" ..
|
"list[current_player;main;0,3;8,4;]" .. get_itemslot_bg(0, 3, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
|
|
||||||
["16"]="size[8,7]".. background ..
|
["16"]="size[8,7]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;0,0;8,2;]"..
|
"list[detached:" .. self._inv_id .. ";main;0,0;8,2;]".. get_itemslot_bg(0, 0, 8, 2) ..
|
||||||
"list[current_player;main;0,3;8,4;]" ..
|
"list[current_player;main;0,3;8,4;]" .. get_itemslot_bg(0, 3, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
|
|
||||||
["24"]="size[8,8]".. background ..
|
["24"]="size[8,8]".. background ..
|
||||||
"list[context:" .. self._inv_id .. ";main;0,0;8,3;]"..
|
"list[detached:" .. self._inv_id .. ";main;0,0;8,3;]".. get_itemslot_bg(0, 0, 8, 3) ..
|
||||||
"list[current_player;main;0,4;8,4;]" ..
|
"list[current_player;main;0,4;8,4;]" .. get_itemslot_bg(0, 4, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
|
|
||||||
["32"]="size[8,9]".. background ..
|
["32"]="size[8,9]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;0,0.3;8,4;]"..
|
"list[detached:" .. self._inv_id .. ";main;0,0.3;8,4;]".. get_itemslot_bg(0, 0.3, 8, 4) ..
|
||||||
"list[current_player;main;0,4.85;8,1;]"..
|
"list[current_player;main;0,5;8,4;]".. get_itemslot_bg(0, 5, 8, 4) ..
|
||||||
"list[current_player;main;0,6.08;8,3;8]"..
|
"listring[]" ..
|
||||||
"listring[context;main]" ..
|
hotbar,
|
||||||
"listring[current_player;main]" ..
|
|
||||||
default.get_hotbar_bg(0,4.85),
|
|
||||||
|
|
||||||
["50"]="size[10,10]".. background ..
|
["50"]="size[10,10]".. background ..
|
||||||
"list[detached:" .. self._inv_id .. ";main;0,0;10,5;]"..
|
"list[detached:" .. self._inv_id .. ";main;0,0;10,5;]".. get_itemslot_bg(0, 0, 10, 5) ..
|
||||||
"list[current_player;main;1,6;8,4;]" ..
|
"list[current_player;main;1,6;8,4;]" .. get_itemslot_bg(1, 6, 8, 4) ..
|
||||||
"listring[]",
|
"listring[]",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local plane_obj = airutils.getPlaneFromPlayer(player)
|
local plane_obj = airutils.getPlaneFromPlayer(player)
|
||||||
if plane_obj == nil then
|
if plane_obj == nil then
|
||||||
minetest.close_formspec(name, "lib_planes:adf_main")
|
minetest.close_formspec(name, "lib_planes:adf_main")
|
||||||
|
minetest.chat_send_player(name, core.colorize('#ff0000', " >>> There is something wrong with the plane..."))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local ent = plane_obj:get_luaentity()
|
local ent = plane_obj:get_luaentity()
|
||||||
|
@ -230,24 +231,29 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if fields.adf then
|
if fields.adf then
|
||||||
if ent._adf == true then
|
if ent._adf == true then
|
||||||
ent._adf = false
|
ent._adf = false
|
||||||
|
minetest.chat_send_player(name, core.colorize('#0000ff', " >>> ADF deactivated."))
|
||||||
else
|
else
|
||||||
ent._adf = true
|
ent._adf = true
|
||||||
|
minetest.chat_send_player(name, core.colorize('#00ff00', " >>> ADF activated."))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if fields.save_adf then
|
if fields.save_adf then
|
||||||
if ent._adf_destiny then
|
if ent._adf_destiny then
|
||||||
if fields.adf_x then
|
if fields.adf_x and fields.adf_z then
|
||||||
if tonumber(fields.adf_x, 10) ~= nil then
|
if tonumber(fields.adf_x, 10) ~= nil and tonumber(fields.adf_z, 10) ~= nil then
|
||||||
ent._adf_destiny.x = tonumber(fields.adf_x, 10)
|
ent._adf_destiny.x = tonumber(fields.adf_x, 10)
|
||||||
end
|
|
||||||
end
|
|
||||||
if fields.adf_z then
|
|
||||||
if tonumber(fields.adf_z, 10) ~= nil then
|
|
||||||
ent._adf_destiny.z = tonumber(fields.adf_z, 10)
|
ent._adf_destiny.z = tonumber(fields.adf_z, 10)
|
||||||
|
minetest.chat_send_player(name, core.colorize('#00ff00', " >>> Destination written successfully."))
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(name, core.colorize('#ff0000', " >>> There is something wrong with the ADF fields values."))
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(name, core.colorize('#ff0000', " >>> Both ADF fields must be given to complete the operation."))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(name, core.colorize('#ff0000', " >>> There is something wrong on ADF saving..."))
|
||||||
end
|
end
|
||||||
minetest.close_formspec(name, "lib_planes:adf_main")
|
minetest.close_formspec(name, "lib_planes:adf_main")
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,8 +56,13 @@ function airutils.attach(self, player, instructor_mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 1, z = -30})
|
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 1, z = -30})
|
||||||
player_api.player_attached[name] = true
|
if minetest.get_modpath("player_api") then
|
||||||
player_api.set_animation(player, "sit")
|
player_api.player_attached[name] = true
|
||||||
|
player_api.set_animation(player, "sit")
|
||||||
|
elseif minetest.get_modpath("mcl_player") then
|
||||||
|
airutils.sit(player)
|
||||||
|
end
|
||||||
|
|
||||||
-- make the driver sit
|
-- make the driver sit
|
||||||
minetest.after(1, function()
|
minetest.after(1, function()
|
||||||
if player then
|
if player then
|
||||||
|
@ -84,9 +89,14 @@ function airutils.dettachPlayer(self, player)
|
||||||
--player:set_physics_override({speed = 1, jump = 1, gravity = 1, sneak = true})
|
--player:set_physics_override({speed = 1, jump = 1, gravity = 1, sneak = true})
|
||||||
if player then
|
if player then
|
||||||
player:set_detach()
|
player:set_detach()
|
||||||
player_api.player_attached[name] = nil
|
|
||||||
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||||
player_api.set_animation(player, "stand")
|
if minetest.get_modpath("player_api") then
|
||||||
|
player_api.player_attached[name] = nil
|
||||||
|
player_api.set_animation(player, "stand")
|
||||||
|
elseif minetest.get_modpath("mcl_player") then
|
||||||
|
mcl_player.player_attached[name] = nil
|
||||||
|
mcl_player.player_set_animation(player, "stand")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self.driver = nil
|
self.driver = nil
|
||||||
--remove_physics_override(player, {speed=1,gravity=1,jump=1})
|
--remove_physics_override(player, {speed=1,gravity=1,jump=1})
|
||||||
|
@ -114,8 +124,13 @@ local function attach_copilot(self, name, player, eye_y)
|
||||||
-- attach the driver
|
-- attach the driver
|
||||||
player:set_attach(self.co_pilot_seat_base, "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
player:set_attach(self.co_pilot_seat_base, "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 3, z = -30})
|
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 3, z = -30})
|
||||||
player_api.player_attached[name] = true
|
if minetest.get_modpath("player_api") then
|
||||||
player_api.set_animation(player, "sit")
|
player_api.player_attached[name] = true
|
||||||
|
player_api.set_animation(player, "sit")
|
||||||
|
elseif minetest.get_modpath("mcl_player") then
|
||||||
|
mcl_player.player_attached[name] = true
|
||||||
|
airutils.sit(player)
|
||||||
|
end
|
||||||
-- make the driver sit
|
-- make the driver sit
|
||||||
minetest.after(1, function()
|
minetest.after(1, function()
|
||||||
player = minetest.get_player_by_name(name)
|
player = minetest.get_player_by_name(name)
|
||||||
|
@ -170,8 +185,15 @@ function airutils.attach_pax(self, player, is_copilot)
|
||||||
self._passengers[i] = name
|
self._passengers[i] = name
|
||||||
player:set_attach(self._passengers_base[i], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
player:set_attach(self._passengers_base[i], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
player:set_eye_offset({x = 0, y = eye_y, z = 0}, {x = 0, y = 3, z = -30})
|
player:set_eye_offset({x = 0, y = eye_y, z = 0}, {x = 0, y = 3, z = -30})
|
||||||
player_api.player_attached[name] = true
|
|
||||||
player_api.set_animation(player, "sit")
|
if minetest.get_modpath("player_api") then
|
||||||
|
player_api.player_attached[name] = true
|
||||||
|
player_api.set_animation(player, "sit")
|
||||||
|
elseif minetest.get_modpath("mcl_player") then
|
||||||
|
mcl_player.player_attached[name] = true
|
||||||
|
airutils.sit(player)
|
||||||
|
end
|
||||||
|
|
||||||
-- make the driver sit
|
-- make the driver sit
|
||||||
minetest.after(1, function()
|
minetest.after(1, function()
|
||||||
player = minetest.get_player_by_name(name)
|
player = minetest.get_player_by_name(name)
|
||||||
|
@ -208,8 +230,15 @@ function airutils.dettach_pax(self, player)
|
||||||
-- detach the player
|
-- detach the player
|
||||||
if player then
|
if player then
|
||||||
player:set_detach()
|
player:set_detach()
|
||||||
player_api.player_attached[name] = nil
|
|
||||||
player_api.set_animation(player, "stand")
|
if minetest.get_modpath("player_api") then
|
||||||
|
player_api.player_attached[name] = nil
|
||||||
|
player_api.set_animation(player, "stand")
|
||||||
|
elseif minetest.get_modpath("mcl_player") then
|
||||||
|
mcl_player.player_attached[name] = nil
|
||||||
|
mcl_player.player_set_animation(player, "stand")
|
||||||
|
end
|
||||||
|
|
||||||
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||||
--remove_physics_override(player, {speed=1,gravity=1,jump=1})
|
--remove_physics_override(player, {speed=1,gravity=1,jump=1})
|
||||||
end
|
end
|
||||||
|
@ -878,7 +907,6 @@ local function do_attach(self, player, slot)
|
||||||
--minetest.chat_send_all(self.driver_name)
|
--minetest.chat_send_all(self.driver_name)
|
||||||
self._passengers[slot] = name
|
self._passengers[slot] = name
|
||||||
player:set_attach(self._passengers_base[slot], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
player:set_attach(self._passengers_base[slot], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
player_api.player_attached[name] = true
|
|
||||||
|
|
||||||
local eye_y = -4
|
local eye_y = -4
|
||||||
if airutils.detect_player_api(player) == 1 then
|
if airutils.detect_player_api(player) == 1 then
|
||||||
|
@ -886,7 +914,14 @@ local function do_attach(self, player, slot)
|
||||||
end
|
end
|
||||||
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 3, z = -30})
|
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 3, z = -30})
|
||||||
|
|
||||||
player_api.set_animation(player, "sit")
|
if minetest.get_modpath("player_api") then
|
||||||
|
player_api.player_attached[name] = true
|
||||||
|
player_api.set_animation(player, "sit")
|
||||||
|
elseif minetest.get_modpath("mcl_player") then
|
||||||
|
mcl_player.player_attached[name] = true
|
||||||
|
airutils.sit(player)
|
||||||
|
end
|
||||||
|
|
||||||
-- make the driver sit
|
-- make the driver sit
|
||||||
minetest.after(1, function()
|
minetest.after(1, function()
|
||||||
player = minetest.get_player_by_name(name)
|
player = minetest.get_player_by_name(name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue