npc villages log level patch

master
daretmavi 2021-03-14 16:44:33 +01:00
parent 0856bb455f
commit efbf26d769
15 changed files with 42 additions and 42 deletions

View File

@ -72,7 +72,7 @@ npc.texture_check = {
-- Logging
function npc.log(level, message)
if npc.log_level[level] then
minetest.log("verbose","[advanced_npc] "..level..": "..message)
minetest.log("info","[advanced_npc] "..level..": "..message)
end
end
@ -1995,7 +1995,7 @@ function npc.schedule_check(self)
-- Speed is default wandering speed. Target pos is node_pos
-- Calculate dir if dir is random
local dir = npc.commands.get_direction(start_pos, node_pos)
minetest.log("verbose","actions: "..dump(actions[node.name][i]))
minetest.log("info","actions: "..dump(actions[node.name][i]))
if actions[node.name][i].args.dir == "random" then
dir = math.random(0,7)
elseif type(actions[node.name][i].args.dir) == "number" then
@ -2086,7 +2086,7 @@ end
-- and other functions that are assigned to the Lua entity definition
-- This function is executed each time the NPC is loaded
function npc.after_activate(self)
minetest.log("verbose","Self: "..dump(self))
minetest.log("info","Self: "..dump(self))
if not self.actions then
npc.log("WARNING", "Found NPC on bad initialization state: no 'self.actions' object.\nReinitializing...")
npc.initialize(self, self.object:getpos(), true)

View File

@ -448,7 +448,7 @@ function npc.dialogue.start_dialogue(self, player, show_married_dialogue)
dialogue = self.dialogues.normal[math.random(1, #self.dialogues.normal)]
elseif chance >= 90 then
-- Check if gift items hints are enabled
minetest.log("verbose","Self gift data enable: "..dump(self.gift_data.enable_gift_items_hints))
minetest.log("info","Self gift data enable: "..dump(self.gift_data.enable_gift_items_hints))
if self.gift_data.enable_gift_items_hints then
-- Choose a random dialogue line from the favorite/disliked item hints
dialogue = self.dialogues.hints[math.random(1, 4)]

View File

@ -1217,7 +1217,7 @@ function npc.commands.use_sittable(self, args)
end
-- Stand
npc.enqueue_command(self, npc.commands.cmd.STAND, {pos=pos_out_of_sittable, dir=dir})
minetest.log("verbose","Setting sittable at "..minetest.pos_to_string(pos).." as not used")
minetest.log("info","Setting sittable at "..minetest.pos_to_string(pos).." as not used")
if enable_usage_marking then
-- Set place as unused
npc.locations.mark_place_used(pos, npc.locations.USE_STATE.NOT_USED)
@ -1264,7 +1264,7 @@ end
-- going to be considered walkable for the algorithm to find a
-- path.
npc.commands.register_script("advanced_npc:walk_to_pos", function(self, args)
minetest.log("verbose","Received arguments: "..dump(args))
minetest.log("info","Received arguments: "..dump(args))
-- Get arguments for this task
local use_access_node = true
if args.use_access_node ~= nil then
@ -1332,7 +1332,7 @@ npc.commands.register_script("advanced_npc:walk_to_pos", function(self, args)
if use_access_node == true then
dir = npc.commands.get_direction(end_pos, node_pos)
end
minetest.log("verbose","Dir: "..dump(dir))
minetest.log("info","Dir: "..dump(dir))
-- Change dir if using access_node
npc.enqueue_command(self, npc.commands.cmd.STAND, {dir = dir})
break
@ -1488,7 +1488,7 @@ npc.commands.register_script("advanced_npc:idle", function (self, args)
else
-- Set interval
npc.commands.execute(self, npc.commands.cmd.SET_INTERVAL, {interval=obj_search_interval})
minetest.log("verbose","No obj found")
minetest.log("info","No obj found")
end
end
end)
@ -1546,7 +1546,7 @@ npc.commands.register_script_function("advanced_npc:follow", "follow_player", fu
local player_name = args.player_name
local objs = minetest.get_objects_inside_radius(self.object:getpos(), args.radius)
-- Check if objects were found
minetest.log("verbose","Objects found: "..dump(objs))
minetest.log("info","Objects found: "..dump(objs))
if #objs > 0 then
for _,obj in pairs(objs) do
if obj then

View File

@ -216,19 +216,19 @@ function npc.programs.helper.get_pos_argument(self, pos, use_access_node)
local use_access_node = pos.use_access_node or false
local try_alternative_if_used = pos.try_alternative_if_used or false
local places = npc.locations.get_by_type(self, pos.place_type)
minetest.log("verbose","Place type: "..dump(pos.place_type))
minetest.log("verbose","Places: "..dump(places))
minetest.log("info","Place type: "..dump(pos.place_type))
minetest.log("info","Places: "..dump(places))
-- Check index is valid on the places map
if #places >= index then
local place = places[index]
-- Check if place is used, and if it is, find alternative if required
if try_alternative_if_used == true then
minetest.log("verbose","Self places map: "..dump(self.places_map))
minetest.log("verbose","Place category: "..dump(pos.place_category))
minetest.log("verbose","Place type: "..dump(pos.place_type))
minetest.log("verbose","Original Place: "..dump(place))
minetest.log("info","Self places map: "..dump(self.places_map))
minetest.log("info","Place category: "..dump(pos.place_category))
minetest.log("info","Place type: "..dump(pos.place_type))
minetest.log("info","Original Place: "..dump(place))
place = npc.locations.find_unused_place(self, pos.place_category, pos.place_type, place)
minetest.log("verbose","New place: "..dump(place))
minetest.log("info","New place: "..dump(place))
if next(place) ~= nil then
--minetest.log("Mark as used? "..dump(pos.mark_target_as_used))

View File

@ -180,7 +180,7 @@ npc.programs.instr.register("advanced_npc:dig", function(self, args)
npc.add_item_to_inventory(self, drop_itemname, 1)
end
-- Dig node
minetest.log("verbose","Setting air at pos: "..minetest.pos_to_string(pos))
minetest.log("info","Setting air at pos: "..minetest.pos_to_string(pos))
minetest.set_node(pos, {name="air"})
end
end

View File

@ -548,7 +548,7 @@ end
-- furnaces, storage (e.g. chests) and openable (e.g. doors).
-- Returns a table with these classifications
function npc.locations.scan_area_for_usable_nodes(pos1, pos2)
minetest.log("verbose","Bed Nodes: "..dump(npc.locations.nodes.bed))
minetest.log("info","Bed Nodes: "..dump(npc.locations.nodes.bed))
local result = {
bed_type = {},
sittable_type = {},

View File

@ -55,7 +55,7 @@ npc.programs.instr.register("advanced_npc:follow:follow_player", function(self,
local player_name = args.player_name
local objs = minetest.get_objects_inside_radius(self.object:getpos(), args.radius)
-- Check if objects were found
minetest.log("verbose","Objects found: "..dump(objs))
minetest.log("info","Objects found: "..dump(objs))
if #objs > 0 then
for _,obj in pairs(objs) do
if obj then

View File

@ -160,7 +160,7 @@ npc.programs.register("advanced_npc:idle", function(self, args)
-- Set interval
npc.programs.instr.execute(self, "advanced_npc:wait", {time=5})
--npc.programs.instr.execute(self, npc.programs.instr.default.SET_PROCESS_INTERVAL, {interval=obj_search_interval})
minetest.log("verbose","No obj found")
minetest.log("info","No obj found")
end
end
end)

View File

@ -17,7 +17,7 @@ npc.programs.register("advanced_npc:use_sittable", function(self, args)
local node = minetest.get_node(pos)
if action == npc.programs.const.node_ops.sittable.SIT then
minetest.log("verbose","Sitting...")
minetest.log("info","Sitting...")
-- Calculate position depending on bench
-- Error here due to ignore. Need to come up with better solution
if node.name == "ignore" then
@ -54,7 +54,7 @@ npc.programs.register("advanced_npc:use_sittable", function(self, args)
end
-- Stand
npc.programs.instr.execute(self, npc.programs.instr.default.STAND, {pos=pos_out_of_sittable, dir=dir})
minetest.log("verbose","Setting sittable at "..minetest.pos_to_string(pos).." as not used")
minetest.log("info","Setting sittable at "..minetest.pos_to_string(pos).." as not used")
if enable_usage_marking then
-- Set place as unused
npc.locations.mark_place_used(pos, npc.locations.USE_STATE.NOT_USED)

View File

@ -48,7 +48,7 @@ npc.programs.register("advanced_npc:wander", function(self, args)
})
npc.exec.proc.enqueue(self, npc.programs.instr.default.STAND, {})
else
minetest.log("verbose","Walking randomly")
minetest.log("info","Walking randomly")
-- Walk in a random direction
local npc_pos = self.object:getpos()
npc.exec.proc.enqueue(self, npc.programs.instr.default.WALK_STEP, {

View File

@ -65,7 +65,7 @@ npc.texture_check = {
-- Logging
function npc.log(level, message)
if npc.log_level[level] then
minetest.log("verbose","[advanced_npc] "..level..": "..message)
minetest.log("info","[advanced_npc] "..level..": "..message)
end
end
@ -1102,7 +1102,7 @@ function npc.exec.interrupt(self, new_program, new_arguments, interrupt_options)
_exec.priority_enqueue(self,
{[1] = {program_name=new_program, arguments=new_arguments, interrupt_options=interrupt_options}})
--minetest.log("Pause")
minetest.log("verbose","Interrupted process: "..dump(self.execution.process_queue[1]))
minetest.log("info","Interrupted process: "..dump(self.execution.process_queue[1]))
-- Check process - if the instruction queue is empty, do not store
-- Pause current process
_exec.pause_process(self)
@ -1205,7 +1205,7 @@ end
function _exec.restore_process(self)
local current_process = self.execution.process_queue[1]
if current_process then
minetest.log("verbose","Restoring process: "..dump(current_process.program_name))
minetest.log("info","Restoring process: "..dump(current_process.program_name))
-- Change process state
current_process.state = npc.exec.proc.state.RUNNING
-- Check if any instruction was interrupted
@ -1215,7 +1215,7 @@ function _exec.restore_process(self)
-- Restore position
--self.object:setpos(current_process.current_instruction.pos)
-- Execute instruction
minetest.log("verbose","Re-executing instruction: "..dump(current_process.current_instruction.entry.name))
minetest.log("info","Re-executing instruction: "..dump(current_process.current_instruction.entry.name))
_exec.proc.execute(self, current_process.current_instruction.entry)
end
end

View File

@ -387,7 +387,7 @@ function npc.occupations.initialize_occupation_values(self, occupation_name)
self.selected_texture = "default_"..self.gender..".png"
end
end
minetest.log("verbose","Result: "..dump(self.selected_texture))
minetest.log("info","Result: "..dump(self.selected_texture))
-- Set texture and base texture
self.textures = {self.selected_texture}
@ -464,7 +464,7 @@ function npc.occupations.initialize_occupation_values(self, occupation_name)
end
-- Initialize properties
minetest.log("verbose","def.properties: "..dump(def.properties))
minetest.log("info","def.properties: "..dump(def.properties))
if def.properties then
-- Initialize trader status
if def.properties.initial_trader_status then

View File

@ -299,8 +299,8 @@ function npc.spawner.determine_npc_occupation(building_type, workplace_nodes, np
end
else
-- Try to match building type with the occupation local building types
minetest.log("verbose","Building type: "..dump(building_type))
minetest.log("verbose","Occupation local building types: "..dump(local_building_types))
minetest.log("info","Building type: "..dump(building_type))
minetest.log("info","Occupation local building types: "..dump(local_building_types))
for i = 1, #occupation_names do
for j = 1, #local_building_types do
if building_type == local_building_types[j] then
@ -311,7 +311,7 @@ function npc.spawner.determine_npc_occupation(building_type, workplace_nodes, np
end
end
end
minetest.log("verbose","Local building match after: "..dump(result))
minetest.log("info","Local building match after: "..dump(result))
end
end
end
@ -323,9 +323,9 @@ function npc.spawner.determine_npc_occupation(building_type, workplace_nodes, np
-- - If count is less than three (only two NPCs), default_basic occupation.
-- - If count is greater than two, assign any eligible occupation with 50% chance
-- - If not NPC is working, choose an occupation that is not default_basic
minetest.log("verbose","Current building occupations: "..dump(current_building_npc_occupations))
minetest.log("verbose","Result #: "..dump(#result))
minetest.log("verbose","Result: "..dump(result))
minetest.log("info","Current building occupations: "..dump(current_building_npc_occupations))
minetest.log("info","Result #: "..dump(#result))
minetest.log("info","Result: "..dump(result))
if next(current_building_npc_occupations) ~= nil then
for i = 1, #current_building_npc_occupations do
if current_building_npc_occupations[i] ~= npc.occupations.basic_name then
@ -839,7 +839,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Scan for usable nodes
local area_info = npc.spawner.scan_area_for_spawn(start_pos, end_pos, player:get_player_name(), pos)
minetest.log("verbose","Area info: "..dump(area_info))
minetest.log("info","Area info: "..dump(area_info))
-- Assign occupation
local occupation_data = npc.spawner.determine_npc_occupation(
fields.building_type or area_info.building_type,
@ -1094,8 +1094,8 @@ if minetest.get_modpath("mg_villages") ~= nil then
-- TODO: Change formspec to a more detailed one.
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
minetest.log("verbose","NPCs: "..dump(minetest.deserialize(meta:get_string("npcs"))))
minetest.log("verbose","Node data: "..dump(minetest.deserialize(meta:get_string("node_data"))))
minetest.log("info","NPCs: "..dump(minetest.deserialize(meta:get_string("npcs"))))
minetest.log("info","Node data: "..dump(minetest.deserialize(meta:get_string("node_data"))))
return mg_villages.plotmarker_formspec( pos, nil, {}, clicker )
end,
@ -1201,7 +1201,7 @@ minetest.register_chatcommand("restore_area", {
privs = {server = true},
func = function(name, param)
local args = npc.utils.split(param, " ")
minetest.log("verbose","Params: "..dump(args))
minetest.log("info","Params: "..dump(args))
if #args < 2 then
minetest.chat_send_player("Please specify horizontal and vertical radius.")
return

View File

@ -453,8 +453,8 @@ function npc.trade.get_dedicated_trade_offers(self)
-- If it is, create a sell offer, else create a buy offer if possible.
-- Also, avoid creating sell offers immediately if the item was just bought
local item = npc.inventory_contains(self, item_name)
minetest.log("verbose","Searched item: "..dump(item_name))
minetest.log("verbose","Found: "..dump(item))
minetest.log("info","Searched item: "..dump(item_name))
minetest.log("info","Found: "..dump(item))
if item ~= nil and trade_info.last_offer_type ~= npc.trade.OFFER_BUY then
-- Check if item can be sold
if trade_info.item_sold_count == nil

View File

@ -33,7 +33,7 @@ npc.programs.register("mg_villages_npc:farmer:walk_to_field", function(self, arg
-- Get plotmarker
local plotmarker_pos = npc.locations.get_by_type(self, npc.locations.data.other.home_plotmarker)
-- There should always be just one plotmarker
minetest.log("Got: "..dump(plotmarker_pos))
minetest.log("info","Got: "..dump(plotmarker_pos))
plotmarker_pos = plotmarker_pos[1].pos
-- Search building area for gates
local meta = minetest.get_meta(plotmarker_pos)