From 68eb2bed092ff1687991b13e163031fd13f00ac8 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 6 Jun 2022 20:20:04 +0200 Subject: [PATCH] fix regression --- kitz/api/api_log.lua | 6 ++---- kitz/engine.lua | 28 ++++++++-------------------- petz/api/api_on_rightclick.lua | 2 +- petz/brains/bh_breed.lua | 2 ++ petz/petz.conf | 3 +++ petz/settings.lua | 5 +++++ 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/kitz/api/api_log.lua b/kitz/api/api_log.lua index 9e4a76e..8ba7368 100644 --- a/kitz/api/api_log.lua +++ b/kitz/api/api_log.lua @@ -1,11 +1,9 @@ local _id = 0 function kitz.logon_mob(self) - _id = _id + 1 - kitz.active_mobs[_id] = self.object - self._id = _id + table.insert(kitz.active_mobs, self.object) end function kitz.logout_mob(self) - kitz.active_mobs[self._id] = nil + kitz.active_mobs[self.object] = nil end diff --git a/kitz/engine.lua b/kitz/engine.lua index 8c4c4e9..2e7ac04 100644 --- a/kitz/engine.lua +++ b/kitz/engine.lua @@ -582,7 +582,7 @@ function kitz.is_queue_empty_high(self) else return false end end -function kitz.get_nearby_player(self) -- returns random player if nearby or nil +function kitz.get_nearby_player(self) --returns random player if nearby or nil local pos = self.object:get_pos() local range = self.view_range * 0.5 for _, obj in ipairs(minetest.get_connected_players()) do @@ -597,9 +597,11 @@ function kitz.get_nearby_player(self) -- returns random player if nearby or nil return end -function kitz.get_nearby_entity(self,name) -- returns random nearby entity of name or nil +function kitz.get_nearby_entity(self, name) -- returns random nearby entity of name or nil for _,obj in ipairs(kitz.active_mobs) do - if kitz.is_alive(obj) and obj:get_luaentity().name == name then return obj end + if not(self.object == obj) and kitz.is_alive(obj) and obj:get_luaentity().name == name then + return obj + end end return end @@ -610,7 +612,7 @@ function kitz.get_closest_entity(self, name) --returns closest entity of name or local pos = self.object:get_pos() for _, obj in ipairs(kitz.active_mobs) do local luaent = obj:get_luaentity() - if kitz.is_alive(obj) and luaent and luaent.name == name then + if not(self.object == obj) and kitz.is_alive(obj) and luaent and luaent.name == name then local opos = obj:get_pos() local odist = abs(opos.x-pos.x) + abs(opos.z-pos.z) if odist < dist then @@ -801,7 +803,7 @@ function kitz.actfunc(self, staticdata, dtime_s) self.lastvelocity = {x=0,y=0,z=0} end -function kitz.stepfunc(self,dtime,colinfo) -- not intended to be modified +function kitz.stepfunc(self, dtime, colinfo) -- not intended to be modified self.dtime = min(dtime,0.2) self.colinfo = colinfo self.height = kitz.get_box_height(self) @@ -827,22 +829,8 @@ function kitz.stepfunc(self,dtime,colinfo) -- not intended to be modified end self.lastvelocity = self.object:get_velocity() - self.time_total=self.time_total+self.dtime + self.time_total = self.time_total + self.dtime end -- load example behaviors dofile(minetest.get_modpath("kitz") .. "/engine_behaviors.lua") - -minetest.register_on_mods_loaded(function() - local mbkfuns = '' - for n,f in pairs(kitz) do - if type(f) == 'function' then - mbkfuns = mbkfuns .. n .. string.split(minetest.serialize(f),'.lua')[2] or '' - end - end - local crc = minetest.sha1(mbkfuns) --- dbg(crc) --- if crc ~= 'a061770008fe9ecf8e1042a227dc3beabd10e481' then --- minetest.log("error","Mobkit namespace inconsistent, has been modified by other mods.") --- end -end) diff --git a/petz/api/api_on_rightclick.lua b/petz/api/api_on_rightclick.lua index 72d1633..85dea48 100644 --- a/petz/api/api_on_rightclick.lua +++ b/petz/api/api_on_rightclick.lua @@ -90,7 +90,7 @@ petz.on_rightclick = function(self, clicker) else minetest.chat_send_player(clicker:get_player_name(), S("This animal has already been milked.")) end - elseif (self.is_mountable) and (wielded_item_name == "petz:glass_syringe" or wielded_item_name == "petz:glass_syringe_sperm") then + elseif not(petz.settings.disable_syringe) and (self.is_mountable) and (wielded_item_name == "petz:glass_syringe" or wielded_item_name == "petz:glass_syringe_sperm") then if not(self.is_baby) and is_owner then petz.pony_breed(self, clicker, wielded_item, wielded_item_name) end diff --git a/petz/brains/bh_breed.lua b/petz/brains/bh_breed.lua index afded0f..4cfd184 100644 --- a/petz/brains/bh_breed.lua +++ b/petz/brains/bh_breed.lua @@ -11,7 +11,9 @@ function petz.bh_breed(self, pos) local couple_obj = kitz.get_closest_entity(self, couple_name) -- look for a couple if couple_obj then local couple = couple_obj:get_luaentity() + minetest.chat_send_all(tostring(couple.is_male)) if couple and couple.is_rut and not(couple.is_pregnant) and not(couple.is_male) then --if couple and female and is not pregnant and is rut + local couple_pos = couple.object:get_pos() --get couple pos local copulation_distance = petz.settings[self.type.."_copulation_distance"] or 1 if vector.distance(pos, couple_pos) <= copulation_distance then --if close diff --git a/petz/petz.conf b/petz/petz.conf index e5c3299..994f632 100644 --- a/petz/petz.conf +++ b/petz/petz.conf @@ -90,6 +90,7 @@ pregnancy_time = 300 growth_time = 1200 #Only owners can extract some seed from their ponies seed_only_owners = true +disable_syringe = false ##Bloody Mode blood = false @@ -307,6 +308,8 @@ pony_spawn_nodes = default:dirt_with_grass pony_predators = petz:lion,petz:leopard pony_spawn_biome = default pony_spawn_herd = 5 +pony_breed = default:blueberries +pony_copulation_distance = 3 ##Parrot Specific parrot_follow = farming:seed_wheat diff --git a/petz/settings.lua b/petz/settings.lua index df4aecb..e99f47e 100644 --- a/petz/settings.lua +++ b/petz/settings.lua @@ -261,6 +261,11 @@ local settings_def = { type = "boolean", default = true, }, + { + name = "disable_syringe", + type = "boolean", + default = false, + }, --Punch Effect { name = "colorize_punch",