1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-12-24 09:40:21 +01:00

updated to newer 0.4.16 functions

This commit is contained in:
TenPlus1 2017-10-09 11:59:01 +01:00
parent 27fe687f8a
commit 2ffd942c2a
3 changed files with 29 additions and 21 deletions

44
api.lua
View File

@ -1,9 +1,9 @@
-- Mobs Api (4th October 2017)
-- Mobs Api
mobs = {}
mobs.mod = "redo"
mobs.version = "20171004"
mobs.version = "20171009"
-- Intllib
@ -15,6 +15,7 @@ mobs.intllib = S
-- CMI support check
local use_cmi = minetest.global_exists("cmi")
-- Invisibility mod check
mobs.invis = {}
if minetest.global_exists("invisibility") then
@ -22,6 +23,13 @@ if minetest.global_exists("invisibility") then
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
local pi = math.pi
local square = math.sqrt
@ -44,15 +52,15 @@ end
-- Load settings
local damage_enabled = minetest.setting_getbool("enable_damage")
local peaceful_only = minetest.setting_getbool("only_peaceful_mobs")
local disable_blood = minetest.setting_getbool("mobs_disable_blood")
local creative = minetest.setting_getbool("creative_mode")
local spawn_protected = minetest.setting_getbool("mobs_spawn_protected") ~= false
local remove_far = minetest.setting_getbool("remove_far_mobs")
local difficulty = tonumber(minetest.setting_get("mob_difficulty")) or 1.0
local show_health = minetest.setting_getbool("mob_show_health") ~= false
local max_per_block = tonumber(minetest.setting_get("max_objects_per_block") or 99)
local damage_enabled = minetest.settings:get_bool("enable_damage")
local peaceful_only = minetest.settings:get_bool("only_peaceful_mobs")
local disable_blood = minetest.settings:get_bool("mobs_disable_blood")
local creative = minetest.settings:get_bool("creative_mode")
local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false
local remove_far = minetest.settings:get_bool("remove_far_mobs")
local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0
local show_health = minetest.settings:get_bool("mob_show_health") ~= false
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
if peaceful_only then
@ -63,8 +71,8 @@ if peaceful_only then
end
-- calculate aoc range for mob count
local aosrb = tonumber(minetest.setting_get("active_object_send_range_blocks"))
local abr = tonumber(minetest.setting_get("active_block_range"))
local aosrb = tonumber(minetest.settings:get("active_object_send_range_blocks"))
local abr = tonumber(minetest.settings:get("active_block_range"))
local aoc_range = max(aosrb, abr) * 16
-- 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)
-- 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
numbers = numbers:split(",")
@ -3225,7 +3233,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
end
-- if not in creative then take item
if not creative then
if not mobs.is_creative(placer:get_player_name()) then
itemstack:take_item()
end
end
@ -3380,7 +3388,7 @@ function mobs:protect(self, clicker)
return true -- false
end
if not creative then
if not mobs.is_creative(clicker:get_player_name()) then
tool:take_item() -- take 1 protection rune
clicker:set_wielded_item(tool)
end
@ -3413,7 +3421,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
if follow_holding(self, clicker) then
-- 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()
@ -3538,7 +3546,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
update_tag(mob_obj[name])
-- if not in creative then take item
if not creative then
if not mobs.is_creative(name) then
mob_sta[name]:take_item()

View File

@ -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
minetest.register_abm({