mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-25 02:00:21 +01:00
updated to newer 0.4.16 functions
This commit is contained in:
parent
27fe687f8a
commit
2ffd942c2a
44
api.lua
44
api.lua
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
-- Mobs Api (4th October 2017)
|
-- Mobs Api
|
||||||
|
|
||||||
mobs = {}
|
mobs = {}
|
||||||
mobs.mod = "redo"
|
mobs.mod = "redo"
|
||||||
mobs.version = "20171004"
|
mobs.version = "20171009"
|
||||||
|
|
||||||
|
|
||||||
-- Intllib
|
-- Intllib
|
||||||
@ -15,6 +15,7 @@ mobs.intllib = S
|
|||||||
-- CMI support check
|
-- CMI support check
|
||||||
local use_cmi = minetest.global_exists("cmi")
|
local use_cmi = minetest.global_exists("cmi")
|
||||||
|
|
||||||
|
|
||||||
-- Invisibility mod check
|
-- Invisibility mod check
|
||||||
mobs.invis = {}
|
mobs.invis = {}
|
||||||
if minetest.global_exists("invisibility") then
|
if minetest.global_exists("invisibility") then
|
||||||
@ -22,6 +23,13 @@ if minetest.global_exists("invisibility") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- creative check
|
||||||
|
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||||
|
function mobs.is_creative(name)
|
||||||
|
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- localize math functions
|
-- localize math functions
|
||||||
local pi = math.pi
|
local pi = math.pi
|
||||||
local square = math.sqrt
|
local square = math.sqrt
|
||||||
@ -44,15 +52,15 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- Load settings
|
-- Load settings
|
||||||
local damage_enabled = minetest.setting_getbool("enable_damage")
|
local damage_enabled = minetest.settings:get_bool("enable_damage")
|
||||||
local peaceful_only = minetest.setting_getbool("only_peaceful_mobs")
|
local peaceful_only = minetest.settings:get_bool("only_peaceful_mobs")
|
||||||
local disable_blood = minetest.setting_getbool("mobs_disable_blood")
|
local disable_blood = minetest.settings:get_bool("mobs_disable_blood")
|
||||||
local creative = minetest.setting_getbool("creative_mode")
|
local creative = minetest.settings:get_bool("creative_mode")
|
||||||
local spawn_protected = minetest.setting_getbool("mobs_spawn_protected") ~= false
|
local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false
|
||||||
local remove_far = minetest.setting_getbool("remove_far_mobs")
|
local remove_far = minetest.settings:get_bool("remove_far_mobs")
|
||||||
local difficulty = tonumber(minetest.setting_get("mob_difficulty")) or 1.0
|
local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0
|
||||||
local show_health = minetest.setting_getbool("mob_show_health") ~= false
|
local show_health = minetest.settings:get_bool("mob_show_health") ~= false
|
||||||
local max_per_block = tonumber(minetest.setting_get("max_objects_per_block") or 99)
|
local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99)
|
||||||
|
|
||||||
-- Peaceful mode message so players will know there are no monsters
|
-- Peaceful mode message so players will know there are no monsters
|
||||||
if peaceful_only then
|
if peaceful_only then
|
||||||
@ -63,8 +71,8 @@ if peaceful_only then
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- calculate aoc range for mob count
|
-- calculate aoc range for mob count
|
||||||
local aosrb = tonumber(minetest.setting_get("active_object_send_range_blocks"))
|
local aosrb = tonumber(minetest.settings:get("active_object_send_range_blocks"))
|
||||||
local abr = tonumber(minetest.setting_get("active_block_range"))
|
local abr = tonumber(minetest.settings:get("active_block_range"))
|
||||||
local aoc_range = max(aosrb, abr) * 16
|
local aoc_range = max(aosrb, abr) * 16
|
||||||
|
|
||||||
-- pathfinding settings
|
-- pathfinding settings
|
||||||
@ -2802,7 +2810,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
|||||||
interval, chance, aoc, min_height, max_height, day_toggle, on_spawn)
|
interval, chance, aoc, min_height, max_height, day_toggle, on_spawn)
|
||||||
|
|
||||||
-- chance/spawn number override in minetest.conf for registered mob
|
-- chance/spawn number override in minetest.conf for registered mob
|
||||||
local numbers = minetest.setting_get(name)
|
local numbers = minetest.settings:get(name)
|
||||||
|
|
||||||
if numbers then
|
if numbers then
|
||||||
numbers = numbers:split(",")
|
numbers = numbers:split(",")
|
||||||
@ -3225,7 +3233,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- if not in creative then take item
|
-- if not in creative then take item
|
||||||
if not creative then
|
if not mobs.is_creative(placer:get_player_name()) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3380,7 +3388,7 @@ function mobs:protect(self, clicker)
|
|||||||
return true -- false
|
return true -- false
|
||||||
end
|
end
|
||||||
|
|
||||||
if not creative then
|
if not mobs.is_creative(clicker:get_player_name()) then
|
||||||
tool:take_item() -- take 1 protection rune
|
tool:take_item() -- take 1 protection rune
|
||||||
clicker:set_wielded_item(tool)
|
clicker:set_wielded_item(tool)
|
||||||
end
|
end
|
||||||
@ -3413,7 +3421,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
if follow_holding(self, clicker) then
|
if follow_holding(self, clicker) then
|
||||||
|
|
||||||
-- if not in creative then take item
|
-- if not in creative then take item
|
||||||
if not creative then
|
if not mobs.is_creative(clicker:get_player_name()) then
|
||||||
|
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
|
|
||||||
@ -3538,7 +3546,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
update_tag(mob_obj[name])
|
update_tag(mob_obj[name])
|
||||||
|
|
||||||
-- if not in creative then take item
|
-- if not in creative then take item
|
||||||
if not creative then
|
if not mobs.is_creative(name) then
|
||||||
|
|
||||||
mob_sta[name]:take_item()
|
mob_sta[name]:take_item()
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ minetest.register_node("mobs:spawner", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
local max_per_block = tonumber(minetest.setting_get("max_objects_per_block") or 99)
|
local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99)
|
||||||
|
|
||||||
-- spawner abm
|
-- spawner abm
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
Loading…
Reference in New Issue
Block a user