Skip to content

Commit

Permalink
Fixing lint warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
scrain777 committed Oct 12, 2021
1 parent 53175c8 commit 686afa3
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion building_sign/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ minetest.register_node("building_sign:building_marker", {
return true
end,
--on_destruct
after_destruct = function(pos, oldnode)
after_destruct = function() --(pos, oldnode)
--TODO: record sign removal
end,
})
Expand Down
6 changes: 3 additions & 3 deletions working_villagers/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ function working_villages.register_villager(product_name, def)
self.product_name = name
self.manufacturing_number = working_villages.manufacturing_data[name]
working_villages.manufacturing_data[name] = working_villages.manufacturing_data[name] + 1
local inventory = create_inventory(self)
create_inventory(self)

-- attach dummy item to new villager.
minetest.add_entity(self.object:get_pos(), "working_villages:dummy_item")
Expand Down Expand Up @@ -884,7 +884,7 @@ function working_villages.register_villager(product_name, def)

self.object:setvelocity{x = 0, y = 0, z = 0}
self.object:setacceleration{x = 0, y = -self.initial_properties.weight, z = 0}

--legacy
if type(self.pause) == "string" then
self.pause = (self.pause == "resting")
Expand Down Expand Up @@ -1015,7 +1015,7 @@ function working_villages.register_villager(product_name, def)
villager_def.on_rightclick = on_rightclick
villager_def.on_punch = on_punch
villager_def.get_staticdata = get_staticdata

-- storage methods
villager_def.get_stored_table = working_villages.get_stored_villager_table
villager_def.set_stored_table = working_villages.set_stored_villager_table
Expand Down
24 changes: 12 additions & 12 deletions working_villagers/async_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ function working_villages.villager:dig(pos,collect_drops)
if (def_node~=nil) and (def_node.after_dig_node~=nil) then
old_meta = minetest.get_meta(pos):to_table();
end
minetest.remove_node(pos)
local stacks = minetest.get_node_drops(destnode.name)
for _, stack in ipairs(stacks) do
local leftover = self:add_item_to_main(stack)
if not leftover:is_empty() then
minetest.add_item(pos, leftover)
end
end
minetest.remove_node(pos)
local stacks = minetest.get_node_drops(destnode.name)
for _, stack in ipairs(stacks) do
local leftover = self:add_item_to_main(stack)
if not leftover:is_empty() then
minetest.add_item(pos, leftover)
end
end
if (old_meta) then
def_node.after_dig_node(pos, destnode, old_meta, nil)
end
Expand All @@ -136,9 +136,9 @@ function working_villages.villager:dig(pos,collect_drops)
end
self:set_animation(working_villages.animation_frames.STAND)
if collect_drops then
local stacks = minetest.get_node_drops(destnode.name)
local mystacks = minetest.get_node_drops(destnode.name)
--perhaps simplify by just checking if the found item is one of the drops
for _, stack in ipairs(stacks) do
for _, stack in ipairs(mystacks) do
local function is_drop(n)
local name
if type(n) == "table" then
Expand Down Expand Up @@ -241,7 +241,7 @@ function working_villages.villager:place(item,pos)
else
self:set_animation(working_villages.animation_frames.WALK)
end

return true
end

Expand Down Expand Up @@ -334,7 +334,7 @@ function working_villages.villager:goto_bed()
end

function working_villages.villager:handle_night()
local tod = minetest.get_timeofday()
local tod = minetest.get_timeofday()
if tod < 0.2 or tod > 0.76 then
local data = self:get_stored_table();
if (data.in_work == true) then
Expand Down
2 changes: 1 addition & 1 deletion working_villagers/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local init = os.clock()
minetest.log("action", "["..minetest.get_current_modname().."] loading init")
minetest.log("action", "["..minetest.get_current_modname().."] loading init")

working_villages={
modpath = minetest.get_modpath("working_villages"),
Expand Down
4 changes: 2 additions & 2 deletions working_villagers/jobs/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If I have the materials of course. Also I'll look for building markers within a
inventory_image = "default_paper.png^working_villages_builder.png",
jobfunc = function(self)
self:handle_night()

self:count_timer("builder:search")
if self:timer_exceeded("builder:search",20) then
local marker = func.search_surrounding(self.object:get_pos(), find_building, searching_range)
Expand Down Expand Up @@ -133,4 +133,4 @@ If I have the materials of course. Also I'll look for building markers within a
end
end
end,
})
})
6 changes: 3 additions & 3 deletions working_villagers/jobs/follow_player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function follower.walk_in_direction(v,dir)
if dir.y > 1 and minetest.get_item_group(minetest.get_node(position).name,"liquid") > 0 then
v:jump()
end

local velocity = v.object:getvelocity()
if velocity.x==0 and velocity.y==0 then
v:set_animation(working_villages.animation_frames.WALK)
Expand Down Expand Up @@ -34,13 +34,13 @@ function follower.step(v)
if player~=nil then
direction = vector.subtract(player_position, position)
end

if vector.length(direction) < 3 then
--swim upward
if direction.y > 1 and minetest.get_item_group(minetest.get_node(position).name,"liquid") > 0 then
v:jump()
end

follower.stop(v)
else
follower.walk_in_direction(v,direction)
Expand Down
2 changes: 1 addition & 1 deletion working_villagers/jobs/guard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ working_villages.register_job("working_villages:job_guard", {

if escort_target == nil then
--perhaps only wait until the target returns
return co_command.pause, "escort target not on server"
return co_command.pause, "escort target not on server"
end

local target_position = escort_target:get_pos()
Expand Down
6 changes: 3 additions & 3 deletions working_villagers/jobs/plant_collector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ local function find_herb_node(pos)
if (not data) then
return false;
end

if data.collect_only_top then
-- prevent to collect plat part, which can continue to grow
local pos_below = {x=pos.x, y=pos.y-1, z=pos.z}
Expand All @@ -56,7 +56,7 @@ local function find_herb_node(pos)
return false;
end
end

return true;
end

Expand Down Expand Up @@ -87,7 +87,7 @@ working_villages.register_job("working_villages:job_herbcollector", {
local herb_data = herbs.get_herb(minetest.get_node(target).name);
self:dig(target,true)
if herb_data and herb_data.replant then
for index, value in ipairs(herb_data.replant) do
for _, value in ipairs(herb_data.replant) do
self:place(value, target)
end
end
Expand Down
4 changes: 2 additions & 2 deletions working_villagers/jobs/snowclearer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ I'm doing anyway, clearing the snow away.",
inventory_image = "default_paper.png^memorandum_letters.png",
jobfunc = function(self)
self:handle_night()

self:count_timer("snowclearer:search")
self:count_timer("snowclearer:change_dir")
self:handle_obstacles()
Expand All @@ -33,4 +33,4 @@ I'm doing anyway, clearing the snow away.",
self:change_direction_randomly()
end
end,
})
})
7 changes: 4 additions & 3 deletions working_villagers/jobs/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function func.find_path_toward(pos,villager)
end
local val_pos = func.validate_pos(villager.object:get_pos())
--FIXME: this also reverses jump height and fear height
local path,rev = pathfinder.find_path(dest, val_pos, villager)
local _,rev = pathfinder.find_path(dest, val_pos, villager)
return rev
end

Expand Down Expand Up @@ -172,7 +172,7 @@ local owner_griefing_lc = owner_griefing and string.lower(owner_griefing)

if not owner_griefing or owner_griefing_lc == "false" then
-- Villagers may not grief in protected areas.
func.is_protected_owner = function(owner, pos)
func.is_protected_owner = function(_, pos) -- (owner, pos)
return minetest.is_protected(pos, "")
end

Expand Down Expand Up @@ -206,7 +206,8 @@ else

-- Patch areas to support this extension
local prefixlen = #owner_griefing
if minetest.global_exists("areas") then
local areas = rawget(_G, "areas")
if areas then
local areas_player_exists = areas.player_exists
function areas.player_exists(area, name)
local myname = name
Expand Down
2 changes: 1 addition & 1 deletion working_villagers/jobs/woodcutter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ When I find a sappling I'll plant it on some soil near a bright place so a new t
jobfunc = function(self)
self:handle_night()
self:handle_job_pos()

self:count_timer("woodcutter:search")
self:count_timer("woodcutter:change_dir")
self:handle_obstacles()
Expand Down
6 changes: 3 additions & 3 deletions working_villagers/spawn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ local func = working_villages.require("jobs/util")
local log = working_villages.require("log")

local function spawner(initial_job)
return function(pos, node, active_object_count, active_object_count_wider)
return function(pos, _, _, active_object_count_wider)
-- (pos, node, active_object_count, active_object_count_wider)
if active_object_count_wider > 1 then return end
if func.is_protected_owner("working_villages:self_employed",pos) then
return
end

local pos1 = {x=pos.x-4,y=pos.y-8,z=pos.z-4}
local pos2 = {x=pos.x+4,y=pos.y+1,z=pos.z+4}
local spawn_pos
for _,p in ipairs(minetest.find_nodes_in_area_under_air(
pos1,pos2,"group:soil")) do
local above = minetest.get_node({x=p.x,y=p.y+2,z=p.z})
local above_def = minetest.registered_nodes[above.name]
local above_def = minetest.registered_nodes[above.name]
if above_def and not above_def.groups.walkable then
log.action("Spawning a %s at %s", initial_job, minetest.pos_to_string(p,0))
local gender = {
Expand Down
4 changes: 2 additions & 2 deletions working_villagers/storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local cache = {};

-- use key with _ prefix, for non villager data
function working_villages.get_stored_table(key)
local data = cache[key];
local data = cache[key];
if data then
return data;
end
Expand All @@ -28,7 +28,7 @@ end


function working_villages.get_stored_villager_table(self)
local data = cache[self.inventory_name];
local data = cache[self.inventory_name];
if data then
return data;
end
Expand Down
6 changes: 3 additions & 3 deletions working_villagers/talking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ forms.register_text_page("working_villages:job_desc",
local job = villager:get_job()
if not job then
return "I don't have a job."
end
end
return job.long_description or "something..."
end)

forms.put_link("working_villages:talking_menu", "working_villages:job_desc",
"What do you do in your job?")

forms.register_text_page("working_villages:state",
function(villager)
return villager.state_info
end)

forms.put_link("working_villages:talking_menu", "working_villages:state",
"What do you doing at the moment?")

2 changes: 1 addition & 1 deletion working_villagers/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function wv_util.get_eneigbor_offsets(radius,adjacent)
local list = {vector.new()}
local lb = {list[1]}
local hs = {}
for d = 1,r do
for _ = 1,r do
local nb = {}
for _,b in ipairs(lb) do
for _,n in ipairs(a) do
Expand Down
2 changes: 1 addition & 1 deletion working_villagers/util_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local u = working_villages.require("util")
minetest.register_tool("working_villages:neighbor_test_tool", {
description = "neighbor test tool\nplaces wood in euclidean distance",
inventory_image = "working_villages_commanding_sceptre.png",
on_use = function(itemstack, user, pointed_thing)
on_use = function(_, user, pointed_thing) -- (itemstack, user, pointed_thing)
local pos = vector.round(pointed_thing.above)
pos.y = pos.y + 5
for _,n in pairs(u.get_eneigbor_offsets(3)) do
Expand Down

0 comments on commit 686afa3

Please sign in to comment.