tidy code and bug found (thanks hamlet)

This commit is contained in:
TenPlus1 2018-06-17 08:43:52 +01:00
parent 4a5563854d
commit e23f47922b
1 changed files with 17 additions and 18 deletions

35
api.lua
View File

@ -3,7 +3,7 @@
mobs = {} mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
mobs.version = "20180604" mobs.version = "20180617"
-- Intllib -- Intllib
@ -1446,7 +1446,7 @@ local npc_attack = function(self)
return return
end end
local p, sp, obj, min_player local p, sp, obj, min_player, dist
local s = self.object:get_pos() local s = self.object:get_pos()
local min_dist = self.view_range + 1 local min_dist = self.view_range + 1
local objs = minetest.get_objects_inside_radius(s, self.view_range) local objs = minetest.get_objects_inside_radius(s, self.view_range)
@ -2355,7 +2355,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
if self.do_punch then if self.do_punch then
-- when false skip going any further -- when false skip going any further
if self.do_punch(self, hitter, tflp, tool_caps, dir) == false then if self.do_punch(self, hitter, tflp, tool_capabilities, dir) == false then
return return
end end
end end
@ -3333,21 +3333,20 @@ end
-- MarkBu's spawn function -- MarkBu's spawn function
function mobs:spawn(def) function mobs:spawn(def)
local name = def.name mobs:spawn_specific(
local nodes = def.nodes or {"group:soil", "group:stone"} def.name,
local neighbors = def.neighbors or {"air"} def.nodes or {"group:soil", "group:stone"},
local min_light = def.min_light or 0 def.neighbors or {"air"},
local max_light = def.max_light or 15 def.min_light or 0,
local interval = def.interval or 30 def.max_light or 15,
local chance = def.chance or 5000 def.interval or 30,
local active_object_count = def.active_object_count or 1 def.chance or 5000,
local min_height = def.min_height or -31000 def.active_object_count or 1,
local max_height = def.max_height or 31000 def.min_height or -31000,
local day_toggle = def.day_toggle def.max_height or 31000,
local on_spawn = def.on_spawn def.day_toggle,
def.on_spawn
mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval, )
chance, active_object_count, min_height, max_height, day_toggle, on_spawn)
end end