Villager fixes

This commit is contained in:
ancientmarinerdev 2022-10-28 22:02:36 +01:00 committed by cora
parent bf491c35a1
commit cabe299456
1 changed files with 10 additions and 8 deletions

View File

@ -953,8 +953,8 @@ end
local function do_work (self)
--debug_trades(self)
if self.child or self.order == WORK then
mcl_log("A child or already working so don't send to work")
if self.child then
mcl_log("A child so don't send to work")
return
end
--mcl_log("Time for work")
@ -971,7 +971,7 @@ local function do_work (self)
--mcl_log("Villager: ".. minetest.pos_to_string(self.object:get_pos()) .. ", jobsite: " .. minetest.pos_to_string(self._jobsite) .. ", distance to jobsite: ".. distance_to_jobsite)
if distance_to_jobsite < 2 then
if not (self.state == PATHFINDING) then
if self.state ~= PATHFINDING and self.order ~= WORK then
mcl_log("Setting order to work.")
self.order = WORK
unlock_trades(self)
@ -1752,9 +1752,9 @@ mcl_mobs:register_mob("mobs_mc:villager", {
self.attack = nil
end
-- Don't do at night. Go to bed? Maybe do_activity needs it's own method
if validate_jobsite(self) then
if validate_jobsite(self) and not self.order == WORK then
--mcl_mobs:gopath(self,self._jobsite,function()
--minetest.log("arrived at jobsite")
-- minetest.log("sent to jobsite")
--end)
else
self.state = "stand" -- cancel gowp in case it has messed up
@ -1766,11 +1766,13 @@ mcl_mobs:register_mob("mobs_mc:villager", {
local name = clicker:get_player_name()
self._trading_players[name] = true
if self._trades == nil then
if self._trades == nil or self._trades == false then
minetest.log("Trades is nil so init")
init_trades(self)
end
update_max_tradenum(self)
if self._trades == false then
minetest.log("Trades is false. no right click op")
-- Villager has no trades, rightclick is a no-op
return
end