v 20220614 - update boats mod, fix player api detection

* property detect the player api respect engine game version
stable-5.2
Герхард PICCORO Lenz McKAY 2022-06-14 23:54:17 -04:00
parent 07a1de54a0
commit b8ae1c4ccd
2 changed files with 11 additions and 10 deletions

View File

@ -9,7 +9,7 @@ For information check [../README.md](../README.md)
| ------------------ | --------------------------------------------------- | -------- | --- |
| api | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/eb64ff94f82d726e4a55b20fa7ce30e4a7470cc5 | [api](../game_api.md) |
| beds | https://codeberg.org/minenux/minetest-mod-beds | https://codeberg.org/minenux/minetest-mod-beds/commit/a1aac5940c88106b901c00409d7dac942720dd5b | [beds/README.md](beds/README.md) |
| boats | https://codeberg.org/minenux/minetest-mod-boats | https://codeberg.org/minenux/minetest-mod-boats/commit/3832de08f705d5d2e7b5a971760e5fad1653305f | [boats/README.md](boats/README.md) |
| boats | https://codeberg.org/minenux/minetest-mod-boats | https://codeberg.org/minenux/minetest-mod-boats/commit/e412ae84db3c443618b117fb35ae69e3c9bbae10 | [boats/README.md](boats/README.md) |
| bucket | https://codeberg.org/minenux/minetest-mod-bucket.git | https://codeberg.org/minenux/minetest-mod-bucket/commit/1d9f32295aba3ef2a86be302050f34c1766e93d5 | [bucket/README.md](bucket/README.md) |
| butterflies | https://codeberg.org/minenux/minetest-mod-bucket.git | https://codeberg.org/minenux/minetest-mod-bucket/commit/1d9f32295aba3ef2a86be302050f34c1766e93d5 | [bucket/README.md](bucket/README.md) |
| bones | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/eb64ff94f82d726e4a55b20fa7ce30e4a7470cc5 | |

View File

@ -1,11 +1,11 @@
-- boats/init.lua
local is_pa = minetest.get_modpath("player_api")
-- translation support and 5.x version check
local S, is_50, is_53
if minetest.get_translator ~= nil then
S = minetest.get_translator("boats") -- 5.x translation function
is_50 = true
is_53 = false
else
if minetest.get_modpath("intllib") then
dofile(minetest.get_modpath("intllib") .. "/init.lua")
@ -25,7 +25,8 @@ else
end
end
-- check for minetest 5.x compatibility
is_53 = minetest.has_feature("direct_velocity_on_players") or minetest.has_feature("is_creative_enabled") or false
is_50 = has_feature("httpfetch_binary_data")
is_53 = minetest.has_feature("direct_velocity_on_players") or minetest.has_feature("is_creative_enabled") of false
--
-- Helper functions
@ -94,7 +95,7 @@ function boat.on_rightclick(self, clicker)
if self.driver and name == self.driver then
-- Cleanup happens in boat.on_detach_child
clicker:set_detach()
if is_50 then
if is_pa then
player_api.set_animation(clicker, "stand", 30)
else
default.player_set_animation(clicker, "stand", 30)
@ -109,14 +110,14 @@ function boat.on_rightclick(self, clicker)
{x = 0.5, y = 1, z = -3}, {x = 0, y = 0, z = 0})
self.driver = name
if is_50 then
if is_pa then
player_api.player_attached[name] = true
else
default.player_attached[name] = true
end
minetest.after(0.2, function()
if is_50 then
if is_pa then
player_api.set_animation(clicker, "sit", 30)
else
default.player_set_animation(clicker, "sit", 30)
@ -130,7 +131,7 @@ end
-- If driver leaves server while driving boat
function boat.on_detach_child(self, child)
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
else
default.player_attached[child:get_player_name()] = false
@ -164,7 +165,7 @@ function boat.on_punch(self, puncher)
if self.driver and name == self.driver then
self.driver = nil
puncher:set_detach()
if is_50 then
if is_pa then
player_api.player_attached[name] = false
else
default.player_attached[name] = false
@ -309,7 +310,7 @@ function boat.on_step(self, dtime)
local driver_objref = minetest.get_player_by_name(self.driver)
default.player_attached[self.driver] = false
driver_objref:set_detach()
if is_50 then
if is_pa then
player_api.set_animation(driver_objref, "stand" , 30)
else
default.player_set_animation(driver_objref, "stand" , 30)