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) 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 if not self.replace_rate or not self.replace_what or self.child == true or self.object:get_velocity().y ~= 0
return false or math.random(1, self.replace_rate) > 1 then
return false
end end
local pos = self.object:get_pos() local pos = self.object:get_pos()
local what, with, y_offset 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 if #minetest.find_nodes_in_area(pos, pos, what) > 0 then
minetest.set_node(pos, {name = with}) minetest.set_node(pos, {name = with})
if sound_name then 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 end
return true return true
else 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_on_deactivate.lua"))()
assert(loadfile(modpath .. "/api/api_wagon.lua"))() assert(loadfile(modpath .. "/api/api_wagon.lua"))()
assert(loadfile(modpath .. "/api/api_saddles.lua"))() assert(loadfile(modpath .. "/api/api_saddles.lua"))()

View File

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

View File

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