From 232f5df95f9f160cce5b0d59e79c7e0eb47f04fe Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Fri, 3 Mar 2023 21:20:12 -0300 Subject: [PATCH] fixes and priv to anchor added --- entities.lua | 10 ++++++++-- forms.lua | 4 ++-- init.lua | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/entities.lua b/entities.lua index e19b110..e2d9da2 100755 --- a/entities.lua +++ b/entities.lua @@ -106,7 +106,7 @@ local function right_click_controls(self, clicker) if ship_self.owner == "" then ship_self.owner = name end - + local can_bypass = minetest.check_player_privs(clicker, {protection_bypass=true}) if ship_self.driver_name ~= nil and ship_self.driver_name ~= "" then --shows pilot formspec if name == ship_self.driver_name then @@ -556,6 +556,12 @@ minetest.register_entity("ap_airship:airship", { accel.y = accel_y newpitch = velocity.y * math.rad(1.5) * (longit_speed/3) + + local noded = airutils.nodeatpos(airutils.pos_shift(curr_pos,{y=-4.5})) + if (noded and noded.drawtype ~= 'airlike') or self.isonground then + newpitch = 0 + end + self.object:set_acceleration(accel) self.object:set_rotation({x=newpitch,y=newyaw,z=newroll}) @@ -567,7 +573,7 @@ minetest.register_entity("ap_airship:airship", { self.object:set_bone_position("timao", {x=0,y=-22.562,z=176.018}, {x=0,y=0,z=self._rudder_angle*8}) self.object:set_bone_position("compass_axis", {x=0,y=-21.8,z=178.757}, {x=0, y=S_angle, z=0}) - local noded = airutils.nodeatpos(airutils.pos_shift(curr_pos,{y=-3.7})) + noded = airutils.nodeatpos(airutils.pos_shift(curr_pos,{y=-3.7})) if (noded and noded.drawtype ~= 'airlike') or self.isonground then self.object:set_bone_position("door", {x=0,y=-13.1266,z=54.1922}, {x=-18,y=0,z=0}) else diff --git a/forms.lua b/forms.lua index c1d70e8..a692c32 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 - local is_admin = minetest.check_player_privs(player, {server=true}) --force stop by admins - if (math.abs(ent._longit_speed) < max_speed_anchor and ent.isonground) or is_admin then + local can_anchor = minetest.check_player_privs(player, {ap_airship_anchor=true}) --force stop + if (math.abs(ent._longit_speed) < max_speed_anchor and ent.isonground) or can_anchor 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 cdc611a..377a961 100755 --- a/init.lua +++ b/init.lua @@ -100,6 +100,12 @@ function ap_airship.minmax(v,m) return math.min(math.abs(v),m)*ap_airship.sign(v) end + +minetest.register_privilege("ap_airship_anchor", { + description = "The player can anchor the airship anywhere in any speed", + give_to_singleplayer = false +}) + ----------- -- items -----------