mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-26 02:30:21 +01:00
tweak for mineclone and 5.x
This commit is contained in:
parent
5e96602085
commit
131c932aa6
27
api.lua
27
api.lua
@ -1,30 +1,25 @@
|
|||||||
-- Check for translation method
|
-- Translation support
|
||||||
local S
|
local S = minetest.get_translator("mobs")
|
||||||
if minetest.get_translator then
|
|
||||||
S = minetest.get_translator("mobs") -- 5.x translation function
|
|
||||||
else -- boilerplate function
|
|
||||||
S = function(str, ...)
|
|
||||||
local args = {...}
|
|
||||||
return str:gsub("@%d+", function(match)
|
|
||||||
return args[tonumber(match:sub(2))]
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- CMI support check
|
-- CMI support check
|
||||||
local use_cmi = minetest.global_exists("cmi")
|
local use_cmi = minetest.global_exists("cmi")
|
||||||
|
|
||||||
|
-- MineClone2 check
|
||||||
|
local use_mc2 = minetest.get_modpath("mcl_core")
|
||||||
|
|
||||||
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230808",
|
version = "20230809",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
node_snow = minetest.registered_aliases["mapgen_snow"] or "mcl_core:snow",
|
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||||
node_dirt = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
or (use_mc2 and "mcl_core:snow") or "default:snow",
|
||||||
|
node_dirt = minetest.registered_aliases["mapgen_dirt"]
|
||||||
|
or (use_mc2 and "mcl_core:dirt") or "default:dirt"
|
||||||
}
|
}
|
||||||
mobs.fallback_node = mobs.node_dirt
|
mobs.fallback_node = mobs.node_dirt
|
||||||
|
|
||||||
|
|
||||||
-- localize common functions
|
-- localize common functions
|
||||||
local pi = math.pi
|
local pi = math.pi
|
||||||
local square = math.sqrt
|
local square = math.sqrt
|
||||||
|
3
init.lua
3
init.lua
@ -21,6 +21,9 @@ dofile(path .. "/crafts.lua")
|
|||||||
dofile(path .. "/spawner.lua")
|
dofile(path .. "/spawner.lua")
|
||||||
|
|
||||||
-- Lucky Blocks
|
-- Lucky Blocks
|
||||||
|
if minetest.get_modpath("lucky_block") then
|
||||||
dofile(path .. "/lucky_block.lua")
|
dofile(path .. "/lucky_block.lua")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
print("[MOD] Mobs Redo loaded")
|
print("[MOD] Mobs Redo loaded")
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
|
||||||
if minetest.get_modpath("lucky_block") then
|
|
||||||
|
|
||||||
lucky_block:add_blocks({
|
lucky_block:add_blocks({
|
||||||
{"dro", {"mobs:meat_raw"}, 5},
|
{"dro", {"mobs:meat_raw"}, 5},
|
||||||
{"dro", {"mobs:meat"}, 5},
|
{"dro", {"mobs:meat"}, 5},
|
||||||
@ -15,4 +13,3 @@ if minetest.get_modpath("lucky_block") then
|
|||||||
{"dro", {"mobs:fence_top"}, 12},
|
{"dro", {"mobs:fence_top"}, 12},
|
||||||
{"lig"}
|
{"lig"}
|
||||||
})
|
})
|
||||||
end
|
|
||||||
|
33
mount.lua
33
mount.lua
@ -1,8 +1,9 @@
|
|||||||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||||
|
|
||||||
--[[ one of these is needed (for now) to ride mobs, otherwise no riding for you
|
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 check
|
||||||
if not minetest.get_modpath("default")
|
|
||||||
or not minetest.get_modpath("player_api") then
|
-- one of these is needed to ride mobs, otherwise no riding for you
|
||||||
|
if not minetest.get_modpath("player_api") and not is_mc2 then
|
||||||
|
|
||||||
function mobs.attach() end
|
function mobs.attach() end
|
||||||
function mobs.detach() end
|
function mobs.detach() end
|
||||||
@ -11,11 +12,8 @@ or not minetest.get_modpath("player_api") then
|
|||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
]]
|
|
||||||
|
|
||||||
local is_50 = minetest.get_modpath("player_api") -- 5.x compatibility
|
|
||||||
local is_mc2 = minetest.get_modpath("mcl_mobs") -- MineClone2 compatibility
|
|
||||||
|
|
||||||
|
-- Localise some functions
|
||||||
local abs, cos, floor, sin, sqrt, pi =
|
local abs, cos, floor, sin, sqrt, pi =
|
||||||
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi
|
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi
|
||||||
|
|
||||||
@ -105,15 +103,12 @@ local function force_detach(player)
|
|||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
if is_50 then
|
if is_mc2 then
|
||||||
player_api.player_attached[name] = false
|
|
||||||
player_api.set_animation(player, "stand", 30)
|
|
||||||
elseif is_mc2 then
|
|
||||||
mcl_player.player_attached[player:get_player_name()] = false
|
mcl_player.player_attached[player:get_player_name()] = false
|
||||||
mcl_player.player_set_animation(player, "stand", 30)
|
mcl_player.player_set_animation(player, "stand", 30)
|
||||||
else
|
else
|
||||||
default.player_attached[name] = false
|
player_api.player_attached[name] = false
|
||||||
default.player_set_animation(player, "stand", 30)
|
player_api.set_animation(player, "stand", 30)
|
||||||
end
|
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})
|
||||||
@ -206,12 +201,10 @@ function mobs.attach(entity, player)
|
|||||||
|
|
||||||
force_detach(player)
|
force_detach(player)
|
||||||
|
|
||||||
if is_50 then
|
if is_mc2 then
|
||||||
player_api.player_attached[player:get_player_name()] = true
|
|
||||||
elseif is_mc2 then
|
|
||||||
mcl_player.player_attached[player:get_player_name()] = true
|
mcl_player.player_attached[player:get_player_name()] = true
|
||||||
else
|
else
|
||||||
default.player_attached[player:get_player_name()] = true
|
player_api.player_attached[player:get_player_name()] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
||||||
@ -228,12 +221,10 @@ function mobs.attach(entity, player)
|
|||||||
|
|
||||||
if is_player(player) then
|
if is_player(player) then
|
||||||
|
|
||||||
if is_50 then
|
if is_mc2 then
|
||||||
player_api.set_animation(player, "sit", 30)
|
|
||||||
elseif is_mc2 then
|
|
||||||
mcl_player.player_set_animation(player, "sit_mount" , 30)
|
mcl_player.player_set_animation(player, "sit_mount" , 30)
|
||||||
else
|
else
|
||||||
default.player_set_animation(player, "sit", 30)
|
player_api.set_animation(player, "sit", 30)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user