355 lines
18 KiB
Diff
355 lines
18 KiB
Diff
diff --git a/backup/npc.lua.bkp.before.process.lua b/backup/npc.lua.bkp.before.process.lua
|
|
index 6134e46..89db0d5 100644
|
|
--- a/backup/npc.lua.bkp.before.process.lua
|
|
+++ b/backup/npc.lua.bkp.before.process.lua
|
|
@@ -72,7 +72,7 @@ npc.texture_check = {
|
|
-- Logging
|
|
function npc.log(level, message)
|
|
if npc.log_level[level] then
|
|
- minetest.log("[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("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("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)
|
|
diff --git a/dialogue.lua b/dialogue.lua
|
|
index f6968be..783dad2 100644
|
|
--- a/dialogue.lua
|
|
+++ b/dialogue.lua
|
|
@@ -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("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)]
|
|
diff --git a/executable/actions.lua b/executable/actions.lua
|
|
index cbb18aa..56db8a0 100644
|
|
--- a/executable/actions.lua
|
|
+++ b/executable/actions.lua
|
|
@@ -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("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("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("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("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("Objects found: "..dump(objs))
|
|
+ minetest.log("info","Objects found: "..dump(objs))
|
|
if #objs > 0 then
|
|
for _,obj in pairs(objs) do
|
|
if obj then
|
|
diff --git a/executable/helper.lua b/executable/helper.lua
|
|
index 438c980..3d2414c 100644
|
|
--- a/executable/helper.lua
|
|
+++ b/executable/helper.lua
|
|
@@ -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("Place type: "..dump(pos.place_type))
|
|
- minetest.log("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("Self places map: "..dump(self.places_map))
|
|
- minetest.log("Place category: "..dump(pos.place_category))
|
|
- minetest.log("Place type: "..dump(pos.place_type))
|
|
- minetest.log("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("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))
|
|
diff --git a/executable/instructions/builtin_instructions.lua b/executable/instructions/builtin_instructions.lua
|
|
index b53b359..67ada14 100644
|
|
--- a/executable/instructions/builtin_instructions.lua
|
|
+++ b/executable/instructions/builtin_instructions.lua
|
|
@@ -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("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
|
|
diff --git a/executable/locations.lua b/executable/locations.lua
|
|
index 9605a14..6553b06 100644
|
|
--- a/executable/locations.lua
|
|
+++ b/executable/locations.lua
|
|
@@ -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("Bed Nodes: "..dump(npc.locations.nodes.bed))
|
|
+ minetest.log("info","Bed Nodes: "..dump(npc.locations.nodes.bed))
|
|
local result = {
|
|
bed_type = {},
|
|
sittable_type = {},
|
|
diff --git a/executable/programs/builtin/follow.lua b/executable/programs/builtin/follow.lua
|
|
index ac52b1c..66d5e4e 100644
|
|
--- a/executable/programs/builtin/follow.lua
|
|
+++ b/executable/programs/builtin/follow.lua
|
|
@@ -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("Objects found: "..dump(objs))
|
|
+ minetest.log("info","Objects found: "..dump(objs))
|
|
if #objs > 0 then
|
|
for _,obj in pairs(objs) do
|
|
if obj then
|
|
diff --git a/executable/programs/builtin/idle.lua b/executable/programs/builtin/idle.lua
|
|
index d7891d5..b7b6ddd 100644
|
|
--- a/executable/programs/builtin/idle.lua
|
|
+++ b/executable/programs/builtin/idle.lua
|
|
@@ -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("No obj found")
|
|
+ minetest.log("info","No obj found")
|
|
end
|
|
end
|
|
end)
|
|
diff --git a/executable/programs/builtin/use_sittable.lua b/executable/programs/builtin/use_sittable.lua
|
|
index 2ec7260..30565c1 100644
|
|
--- a/executable/programs/builtin/use_sittable.lua
|
|
+++ b/executable/programs/builtin/use_sittable.lua
|
|
@@ -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("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("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)
|
|
diff --git a/executable/programs/builtin/wander.lua b/executable/programs/builtin/wander.lua
|
|
index 866be02..b9aa741 100644
|
|
--- a/executable/programs/builtin/wander.lua
|
|
+++ b/executable/programs/builtin/wander.lua
|
|
@@ -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("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, {
|
|
diff --git a/npc.lua b/npc.lua
|
|
index 88d7442..a1b16ae 100755
|
|
--- a/npc.lua
|
|
+++ b/npc.lua
|
|
@@ -65,7 +65,7 @@ npc.texture_check = {
|
|
-- Logging
|
|
function npc.log(level, message)
|
|
if npc.log_level[level] then
|
|
- minetest.log("[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("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("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("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
|
|
diff --git a/occupations/occupations.lua b/occupations/occupations.lua
|
|
index 092f451..4108634 100644
|
|
--- a/occupations/occupations.lua
|
|
+++ b/occupations/occupations.lua
|
|
@@ -387,7 +387,7 @@ function npc.occupations.initialize_occupation_values(self, occupation_name)
|
|
self.selected_texture = "default_"..self.gender..".png"
|
|
end
|
|
end
|
|
- minetest.log("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("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
|
|
diff --git a/spawner.lua b/spawner.lua
|
|
index 9c06f3f..3d47a3d 100644
|
|
--- a/spawner.lua
|
|
+++ b/spawner.lua
|
|
@@ -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("Building type: "..dump(building_type))
|
|
- minetest.log("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("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("Current building occupations: "..dump(current_building_npc_occupations))
|
|
- minetest.log("Result #: "..dump(#result))
|
|
- minetest.log("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("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("NPCs: "..dump(minetest.deserialize(meta:get_string("npcs"))))
|
|
- minetest.log("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("Params: "..dump(args))
|
|
+ minetest.log("info","Params: "..dump(args))
|
|
if #args < 2 then
|
|
minetest.chat_send_player("Please specify horizontal and vertical radius.")
|
|
return
|
|
diff --git a/trade/trade.lua b/trade/trade.lua
|
|
index de535fc..56b814f 100644
|
|
--- a/trade/trade.lua
|
|
+++ b/trade/trade.lua
|
|
@@ -451,8 +451,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("Searched item: "..dump(item_name))
|
|
- minetest.log("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
|