Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
jichi authored and jichi committed Dec 3, 2023
1 parent 3e48c68 commit 381bd5f
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 131 deletions.
6 changes: 4 additions & 2 deletions working_villagers/jobs/bone_collector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function bones.is_bone(item_name)
end

local function find_bug_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = bones.get_bone(node.name);
Expand Down Expand Up @@ -118,12 +118,14 @@ working_villages.register_job("working_villages:job_bonecollector", {
self:set_displayed_action("collecting some bones")
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable bones")
self:delay(100)
else
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why collecting failed")
self:delay(100)
Expand Down
6 changes: 4 additions & 2 deletions working_villagers/jobs/brush_collector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function shrubs.is_shrub(item_name)
end

local function find_herb_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = shrubs.get_shrub(node.name);
Expand Down Expand Up @@ -106,12 +106,14 @@ working_villages.register_job("working_villages:job_brushcollector", {
self:set_displayed_action("collecting some brush")
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable brush")
self:delay(100)
else
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why collecting failed")
self:delay(100)
Expand Down
6 changes: 4 additions & 2 deletions working_villagers/jobs/bug_collector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function bugs.is_bug(item_name)
end

local function find_bug_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = bugs.get_bug(node.name);
Expand Down Expand Up @@ -129,12 +129,14 @@ working_villages.register_job("working_villages:job_bugcollector", {
self:set_displayed_action("collecting some bugs")
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable bugs")
self:delay(100)
else
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why collecting failed")
self:delay(100)
Expand Down
39 changes: 31 additions & 8 deletions working_villagers/jobs/farmer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function farming_plants.is_plant(item_name)
end

local function find_plant_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = farming_plants.get_plant(node.name);
Expand Down Expand Up @@ -141,12 +141,35 @@ working_villages.register_job("working_villages:job_farmer", {
end
local plant_name = minetest.get_node(target).name
self:set_displayed_action("farming some "..plant_name)
self:go_to(destination)
local plant_data = farming_plants.get_plant(plant_name);
self:dig(target,true)
if plant_data and plant_data.replant then
for index, value in ipairs(plant_data.replant) do
self:place(value, vector.add(target, vector.new(0,index-1,0)))
--self:go_to(destination)
--local plant_data = farming_plants.get_plant(plant_name);
--self:dig(target,true)
--if plant_data and plant_data.replant then
-- for index, value in ipairs(plant_data.replant) do
-- self:place(value, vector.add(target, vector.new(0,index-1,0)))
-- end
--end

local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable plants")
self:delay(100)
else
local plant_data = farming_plants.get_plant(plant_name);
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why farming failed")
self:delay(100)
else
if plant_data and plant_data.replant then
for index, value in ipairs(plant_data.replant) do
self:place(value, vector.add(target, vector.new(0,index-1,0)))
end
end
end
end
end
Expand Down
52 changes: 30 additions & 22 deletions working_villagers/jobs/gardener.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function gardening_nodes.is_dirt(item_name)
end

local function find_dirt_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = gardening_nodes.get_dirt(node.name);
Expand Down Expand Up @@ -118,28 +118,36 @@ working_villages.register_job("working_villages:job_gardener", {
print("failure: no adjacent walkable found")
destination = target
end
self:go_to(destination)
local plant_name = minetest.get_node(target).name
self:set_displayed_action("tilling some "..plant_name)
local plant_data = gardening_nodes.get_dirt(plant_name)
--self:dig(target,true)
--if plant_data and plant_data.replant then
-- for index, value in ipairs(plant_data.replant) do
-- self:place(value, vector.add(target, vector.new(0,index-1,0)))
-- end
--end
local name = stack:get_name()
if name == nil then return end
local def = minetest.registered_items[name]
if def == nil then return end
local on_use = def.on_use
if on_use == nil then return end
local user = self
local pointed_thing = {under=target, type="node",}
local new_stack = on_use(stack, user, pointed_thing)
-- TODO register position failure ?
self:set_wield_item_stack(new_stack)
for _=0,10 do coroutine.yield() end --wait 10 steps
--self:go_to(destination)
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable dirt")
self:delay(100)
else
local plant_data = gardening_nodes.get_dirt(plant_name)
--self:dig(target,true)
--if plant_data and plant_data.replant then
-- for index, value in ipairs(plant_data.replant) do
-- self:place(value, vector.add(target, vector.new(0,index-1,0)))
-- end
--end
local name = stack:get_name()
if name == nil then return end
local def = minetest.registered_items[name]
if def == nil then return end
local on_use = def.on_use
if on_use == nil then return end
local user = self
local pointed_thing = {under=target, type="node",}
local new_stack = on_use(stack, user, pointed_thing)
-- TODO register position failure ?
self:set_wield_item_stack(new_stack)
for _=0,10 do coroutine.yield() end --wait 10 steps
end
end
elseif self:timer_exceeded("gardener:change_dir",50) then
self:change_direction_randomly()
Expand Down
6 changes: 4 additions & 2 deletions working_villagers/jobs/gem_miner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function gems.is_ore(item_name)
end

local function find_ore_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = gems.get_ore(node.name);
Expand Down Expand Up @@ -128,12 +128,14 @@ working_villages.register_job("working_villages:job_gem_miner", {
-- We may not be able to reach the log
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable rocks")
self:delay(100)
else
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why mining failed")
self:delay(100)
Expand Down
6 changes: 4 additions & 2 deletions working_villagers/jobs/landscaper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function dirts.is_dirt(item_name)
end

local function find_dirt_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = dirts.get_dirt(node.name);
Expand Down Expand Up @@ -139,12 +139,14 @@ working_villages.register_job("working_villages:job_landscaper", {
-- We may not be able to reach the log
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable dirt")
self:delay(100)
else
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why digging failed at (x="..target.x..', y='..target.y..', z='..target.z..')')
self:delay(100)
Expand Down
6 changes: 4 additions & 2 deletions working_villagers/jobs/miner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function stones.is_stone(item_name)
end

local function find_stone_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = stones.get_stone(node.name);
Expand Down Expand Up @@ -135,12 +135,14 @@ working_villages.register_job("working_villages:job_miner", {
-- We may not be able to reach the log
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable rocks")
self:delay(100)
else
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why mining failed at (x="..target.x..', y='..target.y..', z='..target.z..')')
self:delay(100)
Expand Down
6 changes: 4 additions & 2 deletions working_villagers/jobs/plant_collector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function herbs.is_herb(item_name)
end

local function find_herb_node(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = herbs.get_herb(node.name);
Expand Down Expand Up @@ -108,12 +108,14 @@ working_villages.register_job("working_villages:job_herbcollector", {
--herbs.get_herb(minetest.get_node(target).name);
--self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable plant")
self:delay(100)
else
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why collecting failed")
self:delay(100)
Expand Down
2 changes: 2 additions & 0 deletions working_villagers/jobs/snowclearer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ I'm doing anyway, clearing the snow away.",
--self:dig(target,true)
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable snow")
self:delay(100)
else
success, ret = self:dig(target,true)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("confused as to why clearing failed")
self:delay(100)
Expand Down
64 changes: 3 additions & 61 deletions working_villagers/jobs/watercarrier.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function liquids.is_liquid(item_name)
end

local function find_liquid_nodes(pos)
if minetest.is_protected(p, "") then return false end
if working_villages.failed_pos_test(p) then return false end
if minetest.is_protected(pos, "") then return false end
if working_villages.failed_pos_test(pos) then return false end

local node = minetest.get_node(pos);
local data = liquids.get_liquid(node.name);
Expand Down Expand Up @@ -93,6 +93,7 @@ working_villages.register_job("working_villages:job_watercarrier", {
--self:go_to(destination)
local success, ret = self:go_to(destination)
if not success then
assert(target ~= nil)
working_villages.failed_pos_record(target)
self:set_displayed_action("looking at the unreachable snow")
self:delay(100)
Expand Down Expand Up @@ -146,62 +147,3 @@ working_villages.register_job("working_villages:job_watercarrier", {

working_villages.liquids = liquids

-- move to wield item
--local log = working_villages.require("log")
--function working_villages.villager:manipulate_chest2(chest_pos, take_func, put_func, data)
-- if func.is_chest(chest_pos) then
-- -- try to put items
-- local vil_inv = self:get_inventory();
--
-- -- from villager to chest
-- if put_func then
-- local size = vil_inv:get_size("main");
-- for index = 1,size do
-- local stack = vil_inv:get_stack("main", index);
-- if (not stack:is_empty()) and (put_func(self, stack, data)) then
-- local chest_meta = minetest.get_meta(chest_pos);
-- local chest_inv = chest_meta:get_inventory();
-- local leftover = chest_inv:add_item("main", stack);
-- vil_inv:set_stack("main", index, leftover);
-- for _=0,10 do coroutine.yield() end --wait 10 steps
-- end
-- end
-- end
-- -- from chest to villager
-- if take_func then
-- local chest_meta = minetest.get_meta(chest_pos);
-- local chest_inv = chest_meta:get_inventory();
-- local size = chest_inv:get_size("main");
-- for index = 1,size do
-- chest_meta = minetest.get_meta(chest_pos);
-- chest_inv = chest_meta:get_inventory();
-- local stack = chest_inv:get_stack("main", index);
-- if (not stack:is_empty()) and (take_func(self, stack, data)) then
-- local leftover = vil_inv:add_item("wield_item", stack);
-- chest_inv:set_stack("main", index, leftover);
-- for _=0,10 do coroutine.yield() end --wait 10 steps
-- end
-- end
-- end
-- else
-- log.error("Villager %s doe's not find cheston position %s.", self.inventory_name, minetest.pos_to_string(chest_pos))
-- end
--end
--
--function working_villages.villager:handle_chest2(take_func, put_func, data)
-- if (not self.job_data.manipulated_chest2) then
-- local chest_pos = self.pos_data.chest_pos
-- if (chest_pos~=nil) then
-- log.action("villager %s is handling chest at %s", self.inventory_name, minetest.pos_to_string(chest_pos))
-- self:set_state_info("I am taking and puting items from/to my chest.")
-- self:set_displayed_action("active")
-- local chest = minetest.get_node(chest_pos);
-- local dir = minetest.facedir_to_dir(chest.param2);
-- local destination = vector.subtract(chest_pos, dir);
-- self:go_to(destination)
-- self:manipulate_chest2(chest_pos, take_func, put_func, data);
-- end
-- self.job_data.manipulated_chest2 = true;
-- end
--end

Loading

0 comments on commit 381bd5f

Please sign in to comment.