diff --git a/forms.lua b/forms.lua index 995e60c..3e7451a 100755 --- a/forms.lua +++ b/forms.lua @@ -229,8 +229,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if fields.anchor == "true" then local max_speed_anchor = 0.6 if ent._longit_speed then - if math.abs(ent._longit_speed) < max_speed_anchor then - + local is_admin = minetest.check_player_privs(player, {server=true}) --force stop by admins + if (math.abs(ent._longit_speed) < max_speed_anchor and self.isonground) or is_admin then ent.anchored = true ent.object:set_acceleration(vector.new()) ent.object:set_velocity(vector.new()) diff --git a/init.lua b/init.lua index 1c8c772..cdc611a 100755 --- a/init.lua +++ b/init.lua @@ -12,10 +12,10 @@ ap_airship.max_seats = 2 ap_airship.pilot_base_pos = {x=0.0,y=-29,z=170} ap_airship.passenger_pos = { [1] = {x=0.0,y=0,z=60}, - [2] = {x=-11,y=0,z=20}, - [3] = {x=11,y=0,z=20}, - [4] = {x=-11,y=0,z=80}, - [5] = {x=11,y=0,z=80}, + [2] = {x=-32,y=0,z=20}, + [3] = {x=32,y=0,z=20}, + [4] = {x=-32,y=0,z=80}, + [5] = {x=32,y=0,z=80}, } ap_airship.canvas_texture = "wool_white.png^[colorize:#f4e7c1:128" @@ -27,6 +27,8 @@ ap_airship.rotor_texture = "ap_airship_helice.png" ap_airship.textures = { ap_airship.grey_texture, --"ap_airship_painting.png", --balao ap_airship.metal_texture, --ponteira nariz + "ap_airship_brown.png", --mobilia + ap_airship.metal_texture, --mobilia ap_airship.black_texture, -- corpo da bussola ap_airship.metal_texture, -- indicador bussola ap_airship.grey_texture, --"ap_airship_painting.png", --empenagem @@ -46,6 +48,7 @@ ap_airship.textures = { ap_airship.black_texture, --piso "ap_airship_alpha_logo.png", --logo ap_airship.metal_texture, + "wool_red.png", } ap_airship.colors ={ diff --git a/models/ap_airship_mesh.b3d b/models/ap_airship_mesh.b3d index 58febf3..affec18 100755 Binary files a/models/ap_airship_mesh.b3d and b/models/ap_airship_mesh.b3d differ diff --git a/textures/ap_airship_brown.png b/textures/ap_airship_brown.png new file mode 100755 index 0000000..2e8a3bb Binary files /dev/null and b/textures/ap_airship_brown.png differ diff --git a/utilities.lua b/utilities.lua index 4c5adad..42c1a38 100755 --- a/utilities.lua +++ b/utilities.lua @@ -212,6 +212,14 @@ function ap_airship.textures_copy() return tablecopy end +function ap_airship.table_copy(table_here) + local tablecopy = {} + for k, v in pairs(table_here) do + tablecopy[k] = v + end + return tablecopy +end + local function paint(self) local l_textures = ap_airship.textures_copy() for _, texture in ipairs(l_textures) do diff --git a/walk_map.lua b/walk_map.lua index 43a7365..20e1e59 100644 --- a/walk_map.lua +++ b/walk_map.lua @@ -15,17 +15,65 @@ function ap_airship.reclamp(value, min, max) return retVal end +local function is_obstacle_zone(pos, start_point, end_point) + local retVal = ap_airship.table_copy(pos) + + local min_x = 0 + local min_z = 0 + local max_x = 0 + local max_z = 0 + + if start_point.x <= end_point.x then min_x = start_point.x else min_x = end_point.x end + if start_point.z <= end_point.z then min_z = start_point.z else min_z = end_point.z end + if start_point.x > end_point.x then max_x = start_point.x else max_x = end_point.x end + if start_point.z > end_point.z then max_z = start_point.z else max_z = end_point.z end + + local mid_x = (max_x - min_x)/2 + local mid_z = (max_z - min_z)/2 + + if pos.x < max_x and pos.x > min_x+mid_x and + pos.z < max_z and pos.z > min_z then + retVal.x = max_x + 1 + return retVal + end + if pos.x > min_x and pos.x <= min_x+mid_x and + pos.z < max_z and pos.z > min_z then + retVal.x = min_x - 1 + return retVal + end + + if pos.z < max_z and pos.z > min_z+mid_z and + pos.x > min_x and pos.x < max_x then + retVal.z = max_z + 1 + return retVal + end + if pos.z > min_z and pos.z <= min_z+mid_z and + pos.x > min_x and pos.x < max_x then + retVal.z = min_z - 1 + return retVal + end + + return retVal +end + function ap_airship.cabin_map(pos, dpos) local orig_pos = ap_airship.copy_vector(pos) local position = ap_airship.copy_vector(dpos) local new_pos = ap_airship.copy_vector(dpos) + new_pos = is_obstacle_zone(new_pos, {x=12, z=153}, {x=2.5, z=143}) + new_pos = is_obstacle_zone(new_pos, {x=-12, z=153}, {x=-2.5, z=143}) + new_pos = is_obstacle_zone(new_pos, {x=12, z=140}, {x=2.5, z=130}) + new_pos = is_obstacle_zone(new_pos, {x=-12, z=140}, {x=-2.5, z=130}) + new_pos = is_obstacle_zone(new_pos, {x=12, z=127}, {x=2.5, z=117}) + new_pos = is_obstacle_zone(new_pos, {x=-12, z=127}, {x=-2.5, z=117}) + --limit to the cabin new_pos.z = ap_airship.clamp(new_pos.z, 112, 164) new_pos.y = -29 new_pos.x = ap_airship.clamp(new_pos.x, -8.42, 8.42) - --minetest.chat_send_all("x: "..new_pos.x.." - z: "..new_pos.z) + minetest.chat_send_all("x: "..new_pos.x.." - z: "..new_pos.z) return new_pos end @@ -55,6 +103,12 @@ function ap_airship.passengers_deck_map(pos, dpos) --limiting upper deck new_pos.z = ap_airship.clamp(new_pos.z, 3, 109) new_pos.x = ap_airship.clamp(new_pos.x, -43, 43) + + new_pos = is_obstacle_zone(new_pos, {x=30, z=10}, {x=2, z=48}) + new_pos = is_obstacle_zone(new_pos, {x=-30, z=10}, {x=-2, z=48}) + + new_pos = is_obstacle_zone(new_pos, {x=30, z=55}, {x=2, z=90}) + new_pos = is_obstacle_zone(new_pos, {x=-30, z=55}, {x=-2, z=90}) end new_pos.y = 0 @@ -105,6 +159,7 @@ function ap_airship.navigate_deck(pos, dpos, player) end end end + --minetest.chat_send_all(dump(pos_d)) return pos_d end