master
runs 2019-10-18 16:00:51 +02:00
parent e9810c1687
commit d928b7d795
6 changed files with 42 additions and 18 deletions

View File

@ -30,4 +30,4 @@ assert(loadfile(modpath .. "/api/api_silk.lua"))(modpath, S)
assert(loadfile(modpath .. "/api/api_sleep.lua"))(modpath, S)
assert(loadfile(modpath .. "/api/api_env_damage.lua"))(modpath, S)
assert(loadfile(modpath .. "/api/api_on_step.lua"))(modpath, S)
--assert(loadfile(modpath .. "/api/api_bees.lua"))(modpath, S)
assert(loadfile(modpath .. "/api/api_bees.lua"))(modpath, S)

View File

@ -1,5 +1,18 @@
local modpath, S = ...
petz.set_infotext_behive = function(meta, honey_count, bee_count)
meta:set_string("infotext", S("Honey")..": "..tostring(honey_count) .." | "..S("Bees")..": "..tostring(bee_count))
end
petz.behive_exists = function(self)
if self.behive and minetest.get_node_or_nil(self.behive).name == "petz:beehive" then
return true
else
self.behive = nil
return false
end
end
petz.spawn_bee_pos = function(pos) --Check a pos close to a behive to spawn a bee
local pos_1 = {
x = pos.x - 1,
@ -44,7 +57,10 @@ minetest.register_node("petz:beehive", {
local bee = minetest.add_entity(spawn_bee_pos, "petz:bee")
local bee_entity = bee:get_luaentity()
bee_entity.behive = mobkit.remember(bee_entity, "behive", pos)
meta:set_int("bee_count", bee_count - 1)
bee_count = bee_count - 1
meta:set_int("bee_count", bee_count)
local honey_count = meta:get_int("honey_count") or 0
petz.set_infotext_behive(meta, honey_count, bee_count)
end
end
end

View File

@ -55,10 +55,8 @@ petz.file_exists = function(name)
end
for i = 1, #petz.petz_list do --load all the petz.lua files
if petz.settings[petz.petz_list[i].."_spawn"] then
local file_name = modpath .. "/petz/"..petz.petz_list[i].."_"..petz.settings.type_api..".lua"
if petz.file_exists(file_name) then
assert(loadfile(file_name))(S)
end
end
local file_name = modpath .. "/petz/"..petz.petz_list[i].."_"..petz.settings.type_api..".lua"
if petz.file_exists(file_name) then
assert(loadfile(file_name))(S)
end
end

View File

@ -6,6 +6,7 @@ Beaver Fur=Piel de castor
Beaver Oil=Aceite de castor
Beaver=Castor
Bee=Abeja
Bees=Abejas
Beehive=Colmena
Beef=Carne de ternera
Beef Steak=Filete de ternera
@ -52,6 +53,7 @@ Hairbrush= Cepillo para pelo
has abandoned you!!!=te ha abandonado!!!
has been captured=ha sido capturado
has starved to death!!!=ha muerto de hambre!!!
Honey=Miel
Hungry=Hambriento
Infertile=Estéril
It breeds with=Se cría con

View File

@ -390,7 +390,7 @@ function petz.bee_brain(self)
local player = mobkit.get_nearby_player(self)
--search for flowers
if prty < 6 and not(self.pollen) then
if prty < 6 and not(self.pollen) and petz.behive_exists(self) then
local view_range = self.view_range
local nearby_flowers = minetest.find_nodes_in_area(
{x = pos.x - view_range, y = pos.y - 1, z = pos.z - view_range},
@ -403,11 +403,9 @@ function petz.bee_brain(self)
end
--search for the bee behive
if prty < 4 and self.pollen == true then
if self.behive and minetest.get_node_or_nil(self.behive) then ---if behive defined and exits in the pos
if vector.distance(pos, self.behive) <= 12 then
mobkit.hq_gotobehive(self, 4)
end
if prty < 4 and self.pollen == true and petz.behive_exists(self) then
if vector.distance(pos, self.behive) <= 12 then
mobkit.hq_gotobehive(self, 4)
end
end

View File

@ -1,3 +1,5 @@
local modpath, S = ...
--
-- FLY BRAIN
--
@ -355,10 +357,18 @@ function mobkit.lq_search_behive(self)
local func = function(self)
local tpos = self.behive
if mobkit.drive_to_pos(self, tpos, 2.5, 6.28, 0.3) then
self.object:remove()
local meta = minetest.get_meta(tpos)
local bee_count = meta:get_int("bee_count") or 0
meta:set_int("bee_count", bee_count + 1)
if petz.behive_exists(self) then
self.object:remove()
local meta = minetest.get_meta(tpos)
local bee_count = meta:get_int("bee_count") or 0
bee_count = bee_count + 1
meta:set_int("bee_count", bee_count)
local honey_count = meta:get_int("honey_count") or 0
honey_count = honey_count + 1
meta:set_int("honey_count", honey_count)
petz.set_infotext_behive(meta, honey_count, bee_count)
end
self.pollen = false
end
end
mobkit.queue_low(self, func)