tarantulas can be captured with a net

master
runs 2022-04-12 00:01:25 +02:00
parent 6d021c1476
commit dbc6c80ad6
4 changed files with 9 additions and 7 deletions

View File

@ -3,8 +3,9 @@
--
function mokapi.replace(self, sound_name, max_hear_distance)
if not self.replace_rate or not self.replace_what or self.child == true or self.object:get_velocity().y ~= 0 or math.random(1, self.replace_rate) > 1 then
return false
if not self.replace_rate or not self.replace_what or self.child == true or self.object:get_velocity().y ~= 0
or math.random(1, self.replace_rate) > 1 then
return false
end
local pos = self.object:get_pos()
local what, with, y_offset
@ -22,7 +23,8 @@ function mokapi.replace(self, sound_name, max_hear_distance)
if #minetest.find_nodes_in_area(pos, pos, what) > 0 then
minetest.set_node(pos, {name = with})
if sound_name then
mokapi.make_sound("object", self.object, sound_name, max_hear_distance or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE)
mokapi.make_sound("object", self.object, sound_name, max_hear_distance
or mokapi.consts.DEFAULT_MAX_HEAR_DISTANCE)
end
return true
else

View File

@ -43,4 +43,3 @@ assert(loadfile(modpath .. "/api/api_back_home.lua"))()
assert(loadfile(modpath .. "/api/api_on_deactivate.lua"))()
assert(loadfile(modpath .. "/api/api_wagon.lua"))()
assert(loadfile(modpath .. "/api/api_saddles.lua"))()

View File

@ -149,12 +149,13 @@ function petz.herbivore_brain(self)
end
end
end
--search for a petz:pet_bowl or a bale
if prty < 4 and self.tamed then
local view_range = self.view_range
local nearby_nodes = minetest.find_nodes_in_area(
{x = pos.x - view_range, y = pos.y - 1, z = pos.z - view_range},
{x = pos.x + view_range, y = pos.y + 1, z = pos.z + view_range},
{x = pos.x - (view_range/2), y = pos.y - 1, z = pos.z - (view_range/2)},
{x = pos.x + (view_range/2), y = pos.y + 1, z = pos.z + (view_range/2)},
{"group:feeder"})
if #nearby_nodes >= 1 then
local tpos = nearby_nodes[1] --the first match

View File

@ -24,7 +24,7 @@ minetest.register_entity("petz:"..pet_name, {
attack_player = true,
give_orders = false,
can_be_brushed = false,
capture_item = nil,
capture_item = "net",
follow = petz.settings.tarantula_follow,
drops = {
{name = "farming:string", chance = 3, min = 1, max = 1,},