1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-07-22 10:00:28 +02:00

Compare commits

...

6 Commits

4 changed files with 40 additions and 13 deletions

40
api.lua
View File

@ -1,14 +1,34 @@
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S = minetest.get_translator and minetest.get_translator("mobs") or
dofile(MP .. "/intllib.lua")
-- Check for translation method
local S
if minetest.get_translator ~= nil then
S = minetest.get_translator("mobs") -- 5.x translation function
else
if minetest.get_modpath("intllib") then
dofile(minetest.get_modpath("intllib") .. "/init.lua")
if intllib.make_gettext_pair then
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
else
gettext = intllib.Getter() -- old text file method
end
S = gettext
else -- boilerplate function
S = function(str, ...)
local args = {...}
return str:gsub("@%d+", function(match)
return args[tonumber(match:sub(2))]
end)
end
end
end
-- CMI support check
local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20211212",
version = "20220120",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -1002,19 +1022,19 @@ end
-- Returns true is node can deal damage to self
local is_node_dangerous = function(self, nodename)
function mobs:is_node_dangerous(mob_object, nodename)
if self.water_damage > 0
if mob_object.water_damage > 0
and minetest.get_item_group(nodename, "water") ~= 0 then
return true
end
if self.lava_damage > 0
if mob_object.lava_damage > 0
and minetest.get_item_group(nodename, "lava") ~= 0 then
return true
end
if self.fire_damage > 0
if mob_object.fire_damage > 0
and minetest.get_item_group(nodename, "fire") ~= 0 then
return true
end
@ -1026,6 +1046,10 @@ local is_node_dangerous = function(self, nodename)
return false
end
local function is_node_dangerous(mob_object, nodename)
return mobs:is_node_dangerous(mob_object, nodename)
end
-- is mob facing a cliff
function mob_class:is_at_cliff()

View File

@ -691,6 +691,12 @@ space to spawn mob [name], if so then a new position is returned for use,
otherwise nil is returned.
mobs:is_node_dangerous(mob_object, nodename)
This function returns true if the node name given is harmful to the mob (mob_object),
it is mainly used when a mob is near a node it has to avoid.
External Settings for "minetest.conf"
------------------------------------

View File

@ -1,3 +0,0 @@
-- Support for the old multi-load method
return dofile(minetest.get_modpath("intllib").."/init.lua")

View File

@ -218,7 +218,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
end
local acce_y = 0
local velo = entity.object:get_velocity()
local velo = entity.object:get_velocity() ; if not velo then return end
entity.v = get_v(velo) * get_sign(entity.v)
@ -427,7 +427,7 @@ end
-- directional flying routine by D00Med (edited by TenPlus1)
function mobs.fly(entity, _, speed, shoots, arrow, moving_anim, stand_anim)
local ctrl = entity.driver:get_player_control()
local ctrl = entity.driver:get_player_control() ; if not ctrl then return end
local velo = entity.object:get_velocity()
local dir = entity.driver:get_look_dir()
local yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands