mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-07-22 18:10:30 +02:00
Compare commits
6 Commits
6a4a02f3fb
...
18c7f0a422
Author | SHA1 | Date | |
---|---|---|---|
18c7f0a422 | |||
2fb7bf2c66 | |||
f01e8a61d0 | |||
b756aa50f5 | |||
e83620553d | |||
e5d1958e16 |
40
api.lua
40
api.lua
@ -1,14 +1,34 @@
|
|||||||
-- Load support for intllib.
|
|
||||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
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
|
-- CMI support check
|
||||||
local use_cmi = minetest.global_exists("cmi")
|
local use_cmi = minetest.global_exists("cmi")
|
||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20211212",
|
version = "20220120",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -1002,19 +1022,19 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- Returns true is node can deal damage to self
|
-- 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
|
and minetest.get_item_group(nodename, "water") ~= 0 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.lava_damage > 0
|
if mob_object.lava_damage > 0
|
||||||
and minetest.get_item_group(nodename, "lava") ~= 0 then
|
and minetest.get_item_group(nodename, "lava") ~= 0 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.fire_damage > 0
|
if mob_object.fire_damage > 0
|
||||||
and minetest.get_item_group(nodename, "fire") ~= 0 then
|
and minetest.get_item_group(nodename, "fire") ~= 0 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -1026,6 +1046,10 @@ local is_node_dangerous = function(self, nodename)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function is_node_dangerous(mob_object, nodename)
|
||||||
|
return mobs:is_node_dangerous(mob_object, nodename)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- is mob facing a cliff
|
-- is mob facing a cliff
|
||||||
function mob_class:is_at_cliff()
|
function mob_class:is_at_cliff()
|
||||||
|
6
api.txt
6
api.txt
@ -691,6 +691,12 @@ space to spawn mob [name], if so then a new position is returned for use,
|
|||||||
otherwise nil is returned.
|
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"
|
External Settings for "minetest.conf"
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
-- Support for the old multi-load method
|
|
||||||
return dofile(minetest.get_modpath("intllib").."/init.lua")
|
|
||||||
|
|
@ -218,7 +218,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local acce_y = 0
|
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)
|
entity.v = get_v(velo) * get_sign(entity.v)
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ end
|
|||||||
-- directional flying routine by D00Med (edited by TenPlus1)
|
-- directional flying routine by D00Med (edited by TenPlus1)
|
||||||
function mobs.fly(entity, _, speed, shoots, arrow, moving_anim, stand_anim)
|
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 velo = entity.object:get_velocity()
|
||||||
local dir = entity.driver:get_look_dir()
|
local dir = entity.driver:get_look_dir()
|
||||||
local yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands
|
local yaw = entity.driver:get_look_horizontal() + 1.57 -- offset fix between old and new commands
|
||||||
|
Reference in New Issue
Block a user