v 20220728 - update boats mod, fix missing global minetest object access
* property detect the feature using the namespace global var
This commit is contained in:
parent
36427dada6
commit
e02a31343a
@ -1,11 +1,11 @@
|
|||||||
-- boats/init.lua
|
-- boats/init.lua
|
||||||
|
|
||||||
|
local is_pa = minetest.get_modpath("player_api")
|
||||||
|
|
||||||
-- translation support and 5.x version check
|
-- translation support and 5.x version check
|
||||||
local S, is_50, is_53
|
local S, is_50, is_53
|
||||||
if minetest.get_translator ~= nil then
|
if minetest.get_translator ~= nil then
|
||||||
S = minetest.get_translator("boats") -- 5.x translation function
|
S = minetest.get_translator("boats") -- 5.x translation function
|
||||||
is_50 = true
|
|
||||||
is_53 = false
|
|
||||||
else
|
else
|
||||||
if minetest.get_modpath("intllib") then
|
if minetest.get_modpath("intllib") then
|
||||||
dofile(minetest.get_modpath("intllib") .. "/init.lua")
|
dofile(minetest.get_modpath("intllib") .. "/init.lua")
|
||||||
@ -25,6 +25,7 @@ else
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- check for minetest 5.x compatibility
|
-- check for minetest 5.x compatibility
|
||||||
|
is_50 = minetest.has_feature("httpfetch_binary_data")
|
||||||
is_53 = minetest.has_feature("direct_velocity_on_players") or minetest.has_feature("is_creative_enabled") or false
|
is_53 = minetest.has_feature("direct_velocity_on_players") or minetest.has_feature("is_creative_enabled") or false
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -48,12 +49,19 @@ local function get_v(v)
|
|||||||
return math.sqrt(v.x ^ 2 + v.z ^ 2)
|
return math.sqrt(v.x ^ 2 + v.z ^ 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_creative_enabled(name)
|
local creative = minetest.settings:get_bool("creative_mode")
|
||||||
if is_53 then
|
|
||||||
return minetest.is_creative_enabled(name)
|
function is_creative_enabled(name)
|
||||||
else
|
|
||||||
return creative.is_enabled_for(name) or minetest.settings:get_bool("creative_mode")
|
if creative or minetest.check_player_privs(name, {creative = true}) then
|
||||||
|
if is_53 then
|
||||||
|
return minetest.is_creative_enabled(name)
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -87,7 +95,7 @@ function boat.on_rightclick(self, clicker)
|
|||||||
if self.driver and name == self.driver then
|
if self.driver and name == self.driver then
|
||||||
-- Cleanup happens in boat.on_detach_child
|
-- Cleanup happens in boat.on_detach_child
|
||||||
clicker:set_detach()
|
clicker:set_detach()
|
||||||
if is_50 then
|
if is_pa then
|
||||||
player_api.set_animation(clicker, "stand", 30)
|
player_api.set_animation(clicker, "stand", 30)
|
||||||
else
|
else
|
||||||
default.player_set_animation(clicker, "stand", 30)
|
default.player_set_animation(clicker, "stand", 30)
|
||||||
@ -102,14 +110,14 @@ function boat.on_rightclick(self, clicker)
|
|||||||
{x = 0.5, y = 1, z = -3}, {x = 0, y = 0, z = 0})
|
{x = 0.5, y = 1, z = -3}, {x = 0, y = 0, z = 0})
|
||||||
|
|
||||||
self.driver = name
|
self.driver = name
|
||||||
if is_50 then
|
if is_pa then
|
||||||
player_api.player_attached[name] = true
|
player_api.player_attached[name] = true
|
||||||
else
|
else
|
||||||
default.player_attached[name] = true
|
default.player_attached[name] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(0.2, function()
|
minetest.after(0.2, function()
|
||||||
if is_50 then
|
if is_pa then
|
||||||
player_api.set_animation(clicker, "sit", 30)
|
player_api.set_animation(clicker, "sit", 30)
|
||||||
else
|
else
|
||||||
default.player_set_animation(clicker, "sit", 30)
|
default.player_set_animation(clicker, "sit", 30)
|
||||||
@ -123,7 +131,7 @@ end
|
|||||||
-- If driver leaves server while driving boat
|
-- If driver leaves server while driving boat
|
||||||
function boat.on_detach_child(self, child)
|
function boat.on_detach_child(self, child)
|
||||||
if child and child:get_player_name() == self.driver then
|
if child and child:get_player_name() == self.driver then
|
||||||
if is_50 then
|
if is_pa then
|
||||||
player_api.player_attached[child:get_player_name()] = false
|
player_api.player_attached[child:get_player_name()] = false
|
||||||
else
|
else
|
||||||
default.player_attached[child:get_player_name()] = false
|
default.player_attached[child:get_player_name()] = false
|
||||||
@ -157,7 +165,7 @@ function boat.on_punch(self, puncher)
|
|||||||
if self.driver and name == self.driver then
|
if self.driver and name == self.driver then
|
||||||
self.driver = nil
|
self.driver = nil
|
||||||
puncher:set_detach()
|
puncher:set_detach()
|
||||||
if is_50 then
|
if is_pa then
|
||||||
player_api.player_attached[name] = false
|
player_api.player_attached[name] = false
|
||||||
else
|
else
|
||||||
default.player_attached[name] = false
|
default.player_attached[name] = false
|
||||||
@ -302,7 +310,7 @@ function boat.on_step(self, dtime)
|
|||||||
local driver_objref = minetest.get_player_by_name(self.driver)
|
local driver_objref = minetest.get_player_by_name(self.driver)
|
||||||
default.player_attached[self.driver] = false
|
default.player_attached[self.driver] = false
|
||||||
driver_objref:set_detach()
|
driver_objref:set_detach()
|
||||||
if is_50 then
|
if is_pa then
|
||||||
player_api.set_animation(driver_objref, "stand" , 30)
|
player_api.set_animation(driver_objref, "stand" , 30)
|
||||||
else
|
else
|
||||||
default.player_set_animation(driver_objref, "stand" , 30)
|
default.player_set_animation(driver_objref, "stand" , 30)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user