Fix crash when npc close a door
Comment debug messages
This commit is contained in:
parent
dfaa904ba8
commit
97da2dc191
@ -201,7 +201,7 @@ function npc.actions.freeze(self, args)
|
|||||||
local freeze_mobs_api = args.freeze
|
local freeze_mobs_api = args.freeze
|
||||||
local disable_rightclick = args.disable_rightclick
|
local disable_rightclick = args.disable_rightclick
|
||||||
if disable_rightclick ~= nil then
|
if disable_rightclick ~= nil then
|
||||||
npc.log("INFO", "Enabling interactions for NPC "..self.npc_name..": "..dump(not(disable_rightclick)))
|
--npc.log("INFO", "Enabling interactions for NPC "..self.npc_name..": "..dump(not(disable_rightclick)))
|
||||||
self.enable_rightclick_interaction = not(disable_rightclick)
|
self.enable_rightclick_interaction = not(disable_rightclick)
|
||||||
end
|
end
|
||||||
-- minetest.log("Received: "..dump(freeze_mobs_api))
|
-- minetest.log("Received: "..dump(freeze_mobs_api))
|
||||||
@ -751,7 +751,7 @@ end
|
|||||||
function npc.actions.use_furnace(self, args)
|
function npc.actions.use_furnace(self, args)
|
||||||
local pos = get_pos_argument(self, args.pos)
|
local pos = get_pos_argument(self, args.pos)
|
||||||
if pos == nil then
|
if pos == nil then
|
||||||
npc.log("WARNING", "Got nil position in 'use_furnace' using args.pos: "..dump(args.pos))
|
-- npc.log("WARNING", "Got nil position in 'use_furnace' using args.pos: "..dump(args.pos))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -787,16 +787,16 @@ function npc.actions.use_furnace(self, args)
|
|||||||
local fuel_time =
|
local fuel_time =
|
||||||
minetest.get_craft_result({method="fuel", width=1, items={ItemStack(fuel_item.item_string)}}).time
|
minetest.get_craft_result({method="fuel", width=1, items={ItemStack(fuel_item.item_string)}}).time
|
||||||
local total_fuel_time = fuel_time * npc.get_item_count(fuel_item.item_string)
|
local total_fuel_time = fuel_time * npc.get_item_count(fuel_item.item_string)
|
||||||
npc.log("DEBUG", "Fuel time: "..dump(fuel_time))
|
--npc.log("DEBUG", "Fuel time: "..dump(fuel_time))
|
||||||
|
|
||||||
-- Get item to cook's cooking time
|
-- Get item to cook's cooking time
|
||||||
local cook_result =
|
local cook_result =
|
||||||
minetest.get_craft_result({method="cooking", width=1, items={ItemStack(src_item.item_string)}})
|
minetest.get_craft_result({method="cooking", width=1, items={ItemStack(src_item.item_string)}})
|
||||||
local total_cook_time = cook_result.time * npc.get_item_count(item)
|
local total_cook_time = cook_result.time * npc.get_item_count(item)
|
||||||
npc.log("DEBUG", "Cook: "..dump(cook_result))
|
--npc.log("DEBUG", "Cook: "..dump(cook_result))
|
||||||
|
|
||||||
npc.log("DEBUG", "Total cook time: "..total_cook_time
|
-- npc.log("DEBUG", "Total cook time: "..total_cook_time
|
||||||
..", total fuel burn time: "..dump(total_fuel_time))
|
-- ..", total fuel burn time: "..dump(total_fuel_time))
|
||||||
|
|
||||||
-- Check if there is enough fuel to cook all items
|
-- Check if there is enough fuel to cook all items
|
||||||
if total_cook_time > total_fuel_time then
|
if total_cook_time > total_fuel_time then
|
||||||
@ -844,7 +844,7 @@ function npc.actions.use_furnace(self, args)
|
|||||||
npc.add_action(self, npc.actions.cmd.PUT_ITEM, args)
|
npc.add_action(self, npc.actions.cmd.PUT_ITEM, args)
|
||||||
|
|
||||||
-- Now, set NPC to wait until furnace is done.
|
-- Now, set NPC to wait until furnace is done.
|
||||||
npc.log("DEBUG", "Setting wait action for "..dump(total_cook_time))
|
-- npc.log("DEBUG", "Setting wait action for "..dump(total_cook_time))
|
||||||
npc.add_action(self, npc.actions.cmd.SET_INTERVAL, {interval=total_cook_time, freeze=freeze})
|
npc.add_action(self, npc.actions.cmd.SET_INTERVAL, {interval=total_cook_time, freeze=freeze})
|
||||||
|
|
||||||
-- Reset timer
|
-- Reset timer
|
||||||
@ -853,7 +853,7 @@ function npc.actions.use_furnace(self, args)
|
|||||||
-- If freeze is false, then we will have to find the way back to the furnace
|
-- If freeze is false, then we will have to find the way back to the furnace
|
||||||
-- once cooking is done.
|
-- once cooking is done.
|
||||||
if freeze == false then
|
if freeze == false then
|
||||||
npc.log("DEBUG", "Adding walk to position to wandering: "..dump(pos))
|
-- npc.log("DEBUG", "Adding walk to position to wandering: "..dump(pos))
|
||||||
npc.add_task(self, npc.actions.cmd.WALK_TO_POS, {end_pos=pos, walkable={}})
|
npc.add_task(self, npc.actions.cmd.WALK_TO_POS, {end_pos=pos, walkable={}})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -870,7 +870,7 @@ function npc.actions.use_furnace(self, args)
|
|||||||
npc.log("DEBUG", "Taking item back: "..minetest.pos_to_string(pos))
|
npc.log("DEBUG", "Taking item back: "..minetest.pos_to_string(pos))
|
||||||
npc.add_action(self, npc.actions.cmd.TAKE_ITEM, args)
|
npc.add_action(self, npc.actions.cmd.TAKE_ITEM, args)
|
||||||
|
|
||||||
npc.log("DEBUG", "Inventory: "..dump(self.inventory))
|
-- npc.log("DEBUG", "Inventory: "..dump(self.inventory))
|
||||||
|
|
||||||
-- Set furnace as unused if flag is enabled
|
-- Set furnace as unused if flag is enabled
|
||||||
if enable_usage_marking then
|
if enable_usage_marking then
|
||||||
@ -890,7 +890,7 @@ end
|
|||||||
function npc.actions.use_bed(self, args)
|
function npc.actions.use_bed(self, args)
|
||||||
local pos = get_pos_argument(self, args.pos)
|
local pos = get_pos_argument(self, args.pos)
|
||||||
if pos == nil then
|
if pos == nil then
|
||||||
npc.log("WARNING", "Got nil position in 'use_bed' using args.pos: "..dump(args.pos))
|
-- npc.log("WARNING", "Got nil position in 'use_bed' using args.pos: "..dump(args.pos))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local action = args.action
|
local action = args.action
|
||||||
@ -973,7 +973,7 @@ end
|
|||||||
function npc.actions.use_sittable(self, args)
|
function npc.actions.use_sittable(self, args)
|
||||||
local pos = get_pos_argument(self, args.pos)
|
local pos = get_pos_argument(self, args.pos)
|
||||||
if pos == nil then
|
if pos == nil then
|
||||||
npc.log("WARNING", "Got nil position in 'use_sittable' using args.pos: "..dump(args.pos))
|
-- npc.log("WARNING", "Got nil position in 'use_sittable' using args.pos: "..dump(args.pos))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local action = args.action
|
local action = args.action
|
||||||
@ -1068,7 +1068,7 @@ function npc.actions.walk_to_pos(self, args)
|
|||||||
local use_access_node = args.use_access_node or true
|
local use_access_node = args.use_access_node or true
|
||||||
local end_pos, node_pos = get_pos_argument(self, args.end_pos, use_access_node)
|
local end_pos, node_pos = get_pos_argument(self, args.end_pos, use_access_node)
|
||||||
if end_pos == nil then
|
if end_pos == nil then
|
||||||
npc.log("WARNING", "Got nil position in 'walk_to_pos' using args.pos: "..dump(args.end_pos))
|
-- npc.log("WARNING", "Got nil position in 'walk_to_pos' using args.pos: "..dump(args.end_pos))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local enforce_move = args.enforce_move or true
|
local enforce_move = args.enforce_move or true
|
||||||
@ -1128,7 +1128,7 @@ function npc.actions.walk_to_pos(self, args)
|
|||||||
if use_access_node == true then
|
if use_access_node == true then
|
||||||
dir = npc.actions.get_direction(end_pos, node_pos)
|
dir = npc.actions.get_direction(end_pos, node_pos)
|
||||||
end
|
end
|
||||||
minetest.log("Dir: "..dump(dir))
|
-- minetest.log("Dir: "..dump(dir))
|
||||||
-- Change dir if using access_node
|
-- Change dir if using access_node
|
||||||
npc.add_action(self, npc.actions.cmd.STAND, {dir = dir})
|
npc.add_action(self, npc.actions.cmd.STAND, {dir = dir})
|
||||||
break
|
break
|
||||||
@ -1146,6 +1146,8 @@ function npc.actions.walk_to_pos(self, args)
|
|||||||
-- Open door
|
-- Open door
|
||||||
npc.add_action(self, npc.actions.cmd.USE_OPENABLE, {pos=path[i+1].pos, dir=dir, action=npc.actions.const.doors.action.OPEN})
|
npc.add_action(self, npc.actions.cmd.USE_OPENABLE, {pos=path[i+1].pos, dir=dir, action=npc.actions.const.doors.action.OPEN})
|
||||||
|
|
||||||
|
door_opened = true
|
||||||
|
else
|
||||||
door_opened = true
|
door_opened = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1170,9 +1172,10 @@ function npc.actions.walk_to_pos(self, args)
|
|||||||
-- Add extra walk step to ensure that one is standing at other side of openable node
|
-- Add extra walk step to ensure that one is standing at other side of openable node
|
||||||
-- npc.add_action(self, npc.actions.cmd.WALK_STEP, {dir = dir, speed = speed, target_pos = path[i+2].pos})
|
-- npc.add_action(self, npc.actions.cmd.WALK_STEP, {dir = dir, speed = speed, target_pos = path[i+2].pos})
|
||||||
-- Stop to close the door
|
-- Stop to close the door
|
||||||
npc.add_action(self, npc.actions.cmd.STAND, {dir=(dir + 2) % 4 })--, pos=pos_on_close})
|
--npc.add_action(self, npc.actions.cmd.STAND, {dir=(dir + 2) % 4 })--, pos=pos_on_close})
|
||||||
|
npc.add_action(self, npc.actions.cmd.STAND, {dir=dir })--, pos=pos_on_close})
|
||||||
-- Close door
|
-- Close door
|
||||||
npc.add_action(self, npc.actions.cmd.USE_OPENABLE, {pos=path[i+1].pos, action=npc.actions.const.doors.action.CLOSE})
|
npc.add_action(self, npc.actions.cmd.USE_OPENABLE, {pos=path[i+1].pos, dir=dir, action=npc.actions.const.doors.action.CLOSE})
|
||||||
|
|
||||||
door_opened = false
|
door_opened = false
|
||||||
end
|
end
|
||||||
|
@ -67,7 +67,7 @@ function pathfinder.get_decorated_path(path)
|
|||||||
type=pathfinder.is_good_node(node, {})})
|
type=pathfinder.is_good_node(node, {})})
|
||||||
end
|
end
|
||||||
|
|
||||||
npc.log("DEBUG", "Detailed path: "..dump(path_detail))
|
--npc.log("DEBUG", "Detailed path: "..dump(path_detail))
|
||||||
return path_detail
|
return path_detail
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -179,8 +179,8 @@ function npc.places.add_owned_accessible_place(self, nodes, place_type, walkable
|
|||||||
-- Assign node to NPC
|
-- Assign node to NPC
|
||||||
npc.places.add_owned(self, place_type, place_type,
|
npc.places.add_owned(self, place_type, place_type,
|
||||||
nodes[i].node_pos, empty_nodes[1].pos)
|
nodes[i].node_pos, empty_nodes[1].pos)
|
||||||
npc.log("DEBUG", "Added node at "..minetest.pos_to_string(nodes[i].node_pos)
|
-- npc.log("DEBUG", "Added node at "..minetest.pos_to_string(nodes[i].node_pos)
|
||||||
.." to NPC "..dump(self.npc_name))
|
-- .." to NPC "..dump(self.npc_name))
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -227,12 +227,12 @@ function npc.places.mark_place_used(pos, value)
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local used = meta:get_string("advanced_npc:used")
|
local used = meta:get_string("advanced_npc:used")
|
||||||
if value == used then
|
if value == used then
|
||||||
npc.log("WARNING", "Attempted to set 'used' property of node at "
|
-- npc.log("WARNING", "Attempted to set 'used' property of node at "
|
||||||
..minetest.pos_to_string(pos).." to the same value: '"..dump(value).."'")
|
-- ..minetest.pos_to_string(pos).." to the same value: '"..dump(value).."'")
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
meta:set_string("advanced_npc:used", value)
|
meta:set_string("advanced_npc:used", value)
|
||||||
npc.log("DEBUG", "'Used' value at pos "..minetest.pos_to_string(pos)..": "..dump(meta:get_string("advanced_npc:used")))
|
-- npc.log("DEBUG", "'Used' value at pos "..minetest.pos_to_string(pos)..": "..dump(meta:get_string("advanced_npc:used")))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -233,7 +233,7 @@ npc.relationships.register_disliked_item("default:cobble", "male", {
|
|||||||
hints = {"If I really hate something, that's cobblestone!"}
|
hints = {"If I really hate something, that's cobblestone!"}
|
||||||
})
|
})
|
||||||
|
|
||||||
npc.log("DEBUG", "Registered gift items: "..dump(npc.relationships.gift_items))
|
--npc.log("DEBUG", "Registered gift items: "..dump(npc.relationships.gift_items))
|
||||||
npc.log("DEBUG", "Registered dialogues: "..dump(npc.dialogue.registered_dialogues))
|
--npc.log("DEBUG", "Registered dialogues: "..dump(npc.dialogue.registered_dialogues))
|
||||||
npc.log("INFO", "Registered gift items count: "..dump(#npc.relationships.gift_items))
|
npc.log("INFO", "Registered gift items count: "..dump(#npc.relationships.gift_items))
|
||||||
npc.log("INFO", "Registered dialogues count: "..dump(#npc.dialogue.registered_dialogues))
|
npc.log("INFO", "Registered dialogues count: "..dump(#npc.dialogue.registered_dialogues))
|
@ -325,7 +325,7 @@ function npc.dialogue.select_random_dialogues_for_npc(self, phase)
|
|||||||
for i = 1, number_of_dialogues do
|
for i = 1, number_of_dialogues do
|
||||||
local key_id = math.random(1, #keys)
|
local key_id = math.random(1, #keys)
|
||||||
result.normal[i] = keys[key_id]
|
result.normal[i] = keys[key_id]
|
||||||
npc.log("DEBUG", "Adding dialogue: "..dump(dialogues[keys[key_id]]))
|
--npc.log("DEBUG", "Adding dialogue: "..dump(dialogues[keys[key_id]]))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add item hints.
|
-- Add item hints.
|
||||||
@ -352,7 +352,7 @@ function npc.dialogue.select_random_dialogues_for_npc(self, phase)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
npc.log("DEBUG", "Dialogue results:"..dump(result))
|
--npc.log("DEBUG", "Dialogue results:"..dump(result))
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ function npc.dialogue.start_dialogue(self, player, show_married_dialogue)
|
|||||||
dialogue = self.dialogues.normal[math.random(1, #self.dialogues.normal)]
|
dialogue = self.dialogues.normal[math.random(1, #self.dialogues.normal)]
|
||||||
elseif chance >= 90 then
|
elseif chance >= 90 then
|
||||||
-- Check if gift items hints are enabled
|
-- Check if gift items hints are enabled
|
||||||
minetest.log("Self gift data enable: "..dump(self.gift_data.enable_gift_items_hints))
|
--minetest.log("Self gift data enable: "..dump(self.gift_data.enable_gift_items_hints))
|
||||||
if self.gift_data.enable_gift_items_hints then
|
if self.gift_data.enable_gift_items_hints then
|
||||||
-- Choose a random dialogue line from the favorite/disliked item hints
|
-- Choose a random dialogue line from the favorite/disliked item hints
|
||||||
dialogue = self.dialogues.hints[math.random(1, 4)]
|
dialogue = self.dialogues.hints[math.random(1, 4)]
|
||||||
@ -669,7 +669,7 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
|
|||||||
elseif player_response.is_custom_trade_dialogue == true then
|
elseif player_response.is_custom_trade_dialogue == true then
|
||||||
-- Functions for a custom trade should be available from the same dialogue
|
-- Functions for a custom trade should be available from the same dialogue
|
||||||
-- object as they are created on demand
|
-- object as they are created on demand
|
||||||
minetest.log("Player response: "..dump(player_response.options[i]))
|
--minetest.log("Player response: "..dump(player_response.options[i]))
|
||||||
player_response.options[i].action(player_response.npc, player)
|
player_response.options[i].action(player_response.npc, player)
|
||||||
else
|
else
|
||||||
-- Get dialogue from registered dialogues
|
-- Get dialogue from registered dialogues
|
||||||
|
50
npc.lua
50
npc.lua
@ -556,9 +556,9 @@ function npc.initialize(entity, pos, is_lua_entity, npc_stats, occupation_name)
|
|||||||
-- Set initialized flag on
|
-- Set initialized flag on
|
||||||
ent.initialized = true
|
ent.initialized = true
|
||||||
--npc.log("WARNING", "Spawned entity: "..dump(ent))
|
--npc.log("WARNING", "Spawned entity: "..dump(ent))
|
||||||
npc.log("INFO", "Successfully initialized NPC with name "..dump(ent.npc_name)
|
-- npc.log("INFO", "Successfully initialized NPC with name "..dump(ent.npc_name)
|
||||||
..", sex: "..ent.sex..", is child: "..dump(ent.is_child)
|
-- ..", sex: "..ent.sex..", is child: "..dump(ent.is_child)
|
||||||
..", texture: "..dump(ent.textures))
|
-- ..", texture: "..dump(ent.textures))
|
||||||
-- Refreshes entity
|
-- Refreshes entity
|
||||||
ent.object:set_properties(ent)
|
ent.object:set_properties(ent)
|
||||||
end
|
end
|
||||||
@ -745,10 +745,10 @@ end
|
|||||||
-- This function removes the first action in the action queue
|
-- This function removes the first action in the action queue
|
||||||
-- and then executes it
|
-- and then executes it
|
||||||
function npc.execute_action(self)
|
function npc.execute_action(self)
|
||||||
npc.log("DEBUG_ACTION", "Current actions queue: "..dump(self.actions.queue))
|
--npc.log("DEBUG_ACTION", "Current actions queue: "..dump(self.actions.queue))
|
||||||
-- Check if an action was interrupted
|
-- Check if an action was interrupted
|
||||||
if self.actions.current_action_state == npc.action_state.interrupted then
|
if self.actions.current_action_state == npc.action_state.interrupted then
|
||||||
npc.log("DEBUG_ACTION", "Re-inserting interrupted action for NPC: '"..dump(self.npc_name).."': "..dump(self.actions.state_before_lock.interrupted_action))
|
--npc.log("DEBUG_ACTION", "Re-inserting interrupted action for NPC: '"..dump(self.npc_name).."': "..dump(self.actions.state_before_lock.interrupted_action))
|
||||||
-- Insert into queue the interrupted action
|
-- Insert into queue the interrupted action
|
||||||
table.insert(self.actions.queue, 1, self.actions.state_before_lock.interrupted_action)
|
table.insert(self.actions.queue, 1, self.actions.state_before_lock.interrupted_action)
|
||||||
-- Clear the action
|
-- Clear the action
|
||||||
@ -780,7 +780,7 @@ function npc.execute_action(self)
|
|||||||
-- If the entry is a task, then push all this new operations in
|
-- If the entry is a task, then push all this new operations in
|
||||||
-- stack fashion
|
-- stack fashion
|
||||||
if action_obj.is_task == true then
|
if action_obj.is_task == true then
|
||||||
npc.log("DEBUG_ACTION", "Executing task for NPC '"..dump(self.npc_name).."': "..dump(action_obj))
|
--npc.log("DEBUG_ACTION", "Executing task for NPC '"..dump(self.npc_name).."': "..dump(action_obj))
|
||||||
-- Backup current queue
|
-- Backup current queue
|
||||||
local backup_queue = self.actions.queue
|
local backup_queue = self.actions.queue
|
||||||
-- Remove this "task" action from queue
|
-- Remove this "task" action from queue
|
||||||
@ -796,7 +796,7 @@ function npc.execute_action(self)
|
|||||||
table.insert(self.actions.queue, backup_queue[i])
|
table.insert(self.actions.queue, backup_queue[i])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
npc.log("DEBUG_ACTION", "Executing action for NPC '"..dump(self.npc_name).."': "..dump(action_obj))
|
--npc.log("DEBUG_ACTION", "Executing action for NPC '"..dump(self.npc_name).."': "..dump(action_obj))
|
||||||
-- Store the action that is being executed
|
-- Store the action that is being executed
|
||||||
self.actions.state_before_lock.interrupted_action = action_obj
|
self.actions.state_before_lock.interrupted_action = action_obj
|
||||||
-- Store current position
|
-- Store current position
|
||||||
@ -854,7 +854,7 @@ function npc.lock_actions(self)
|
|||||||
-- Freeze mobs_redo API
|
-- Freeze mobs_redo API
|
||||||
self.freeze = false
|
self.freeze = false
|
||||||
|
|
||||||
npc.log("DEBUG_ACTION", "Locking NPC "..dump(self.npc_id).." actions")
|
--npc.log("DEBUG_ACTION", "Locking NPC "..dump(self.npc_id).." actions")
|
||||||
end
|
end
|
||||||
|
|
||||||
function npc.unlock_actions(self)
|
function npc.unlock_actions(self)
|
||||||
@ -883,7 +883,7 @@ function npc.unlock_actions(self)
|
|||||||
self.freeze = true
|
self.freeze = true
|
||||||
end
|
end
|
||||||
|
|
||||||
npc.log("DEBUG_ACTION", "Unlocked NPC "..dump(self.npc_id).." actions")
|
--npc.log("DEBUG_ACTION", "Unlocked NPC "..dump(self.npc_id).." actions")
|
||||||
end
|
end
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------
|
||||||
@ -1044,8 +1044,8 @@ function npc.schedule_change_property(self, property, args)
|
|||||||
local itemlist_entry = itemlist[i]
|
local itemlist_entry = itemlist[i]
|
||||||
local current_itemstring = itemlist[i].name
|
local current_itemstring = itemlist[i].name
|
||||||
if itemlist_entry.random == true then
|
if itemlist_entry.random == true then
|
||||||
current_itemstring = current_itemstring
|
-- current_itemstring = current_itemstring
|
||||||
.." "..dump(math.random(itemlist_entry.min, itemlist_entry.max))
|
-- .." "..dump(math.random(itemlist_entry.min, itemlist_entry.max))
|
||||||
else
|
else
|
||||||
current_itemstring = current_itemstring.." "..tostring(itemlist_entry.count)
|
current_itemstring = current_itemstring.." "..tostring(itemlist_entry.count)
|
||||||
end
|
end
|
||||||
@ -1118,7 +1118,7 @@ end
|
|||||||
-- None-action: array of entries {action=<action_enum>, args={}}.
|
-- None-action: array of entries {action=<action_enum>, args={}}.
|
||||||
-- Will be executed when no node is found.
|
-- Will be executed when no node is found.
|
||||||
function npc.schedule_check(self)
|
function npc.schedule_check(self)
|
||||||
npc.log("DEBUG_SCHEDULE", "Prev Actions queue: "..dump(self.actions.queue))
|
--npc.log("DEBUG_SCHEDULE", "Prev Actions queue: "..dump(self.actions.queue))
|
||||||
local range = self.schedules.current_check_params.range
|
local range = self.schedules.current_check_params.range
|
||||||
local walkable_nodes = self.schedules.current_check_params.walkable_nodes
|
local walkable_nodes = self.schedules.current_check_params.walkable_nodes
|
||||||
local nodes = self.schedules.current_check_params.nodes
|
local nodes = self.schedules.current_check_params.nodes
|
||||||
@ -1129,7 +1129,7 @@ function npc.schedule_check(self)
|
|||||||
-- Search nodes
|
-- Search nodes
|
||||||
local found_nodes = npc.places.find_node_nearby(start_pos, nodes, range)
|
local found_nodes = npc.places.find_node_nearby(start_pos, nodes, range)
|
||||||
-- Check if any node was found
|
-- Check if any node was found
|
||||||
npc.log("DEBUG_SCHEDULE", "Found nodes using radius: "..dump(found_nodes))
|
--npc.log("DEBUG_SCHEDULE", "Found nodes using radius: "..dump(found_nodes))
|
||||||
if found_nodes and #found_nodes > 0 then
|
if found_nodes and #found_nodes > 0 then
|
||||||
local node_pos
|
local node_pos
|
||||||
local node
|
local node
|
||||||
@ -1155,7 +1155,7 @@ function npc.schedule_check(self)
|
|||||||
-- Set node as a place
|
-- Set node as a place
|
||||||
-- Note: Code below isn't *adding* a node, but overwriting the
|
-- Note: Code below isn't *adding* a node, but overwriting the
|
||||||
-- place with "schedule_target_pos" place type
|
-- place with "schedule_target_pos" place type
|
||||||
npc.log("DEBUG_SCHEDULE", "Found "..dump(node.name).." at pos: "..minetest.pos_to_string(node_pos))
|
--npc.log("DEBUG_SCHEDULE", "Found "..dump(node.name).." at pos: "..minetest.pos_to_string(node_pos))
|
||||||
npc.places.add_shared_accessible_place(
|
npc.places.add_shared_accessible_place(
|
||||||
self, {owner="", node_pos=node_pos}, npc.places.PLACE_TYPE.SCHEDULE.TARGET, true, walkable_nodes)
|
self, {owner="", node_pos=node_pos}, npc.places.PLACE_TYPE.SCHEDULE.TARGET, true, walkable_nodes)
|
||||||
-- Get actions related to node and enqueue them
|
-- Get actions related to node and enqueue them
|
||||||
@ -1209,7 +1209,7 @@ function npc.schedule_check(self)
|
|||||||
-- Speed is default wandering speed. Target pos is node_pos
|
-- Speed is default wandering speed. Target pos is node_pos
|
||||||
-- Calculate dir if dir is random
|
-- Calculate dir if dir is random
|
||||||
local dir = npc.actions.get_direction(start_pos, node_pos)
|
local dir = npc.actions.get_direction(start_pos, node_pos)
|
||||||
minetest.log("actions: "..dump(actions[node.name][i]))
|
--minetest.log("actions: "..dump(actions[node.name][i]))
|
||||||
if actions[node.name][i].args.dir == "random" then
|
if actions[node.name][i].args.dir == "random" then
|
||||||
dir = math.random(0,7)
|
dir = math.random(0,7)
|
||||||
elseif type(actions[node.name][i].args.dir) == "number" then
|
elseif type(actions[node.name][i].args.dir) == "number" then
|
||||||
@ -1271,7 +1271,7 @@ function npc.schedule_check(self)
|
|||||||
< self.schedules.current_check_params.execution_times then
|
< self.schedules.current_check_params.execution_times then
|
||||||
npc.add_schedule_check(self)
|
npc.add_schedule_check(self)
|
||||||
end
|
end
|
||||||
npc.log("DEBUG_SCHEDULE", "Actions queue: "..dump(self.actions.queue))
|
--npc.log("DEBUG_SCHEDULE", "Actions queue: "..dump(self.actions.queue))
|
||||||
else
|
else
|
||||||
-- No nodes found, enqueue none_actions
|
-- No nodes found, enqueue none_actions
|
||||||
for i = 1, #none_actions do
|
for i = 1, #none_actions do
|
||||||
@ -1289,7 +1289,7 @@ function npc.schedule_check(self)
|
|||||||
npc.add_schedule_check(self)
|
npc.add_schedule_check(self)
|
||||||
end
|
end
|
||||||
-- No nodes found
|
-- No nodes found
|
||||||
npc.log("DEBUG_SCHEDULE", "Actions queue: "..dump(self.actions.queue))
|
--npc.log("DEBUG_SCHEDULE", "Actions queue: "..dump(self.actions.queue))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1333,7 +1333,7 @@ function npc.rightclick_interaction(self, clicker)
|
|||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
local name = clicker:get_player_name()
|
local name = clicker:get_player_name()
|
||||||
|
|
||||||
npc.log("DEBUG", "Right-clicked NPC: "..dump(self))
|
--npc.log("DEBUG", "Right-clicked NPC: "..dump(self))
|
||||||
|
|
||||||
-- Receive gift or start chat. If player has no item in hand
|
-- Receive gift or start chat. If player has no item in hand
|
||||||
-- then it is going to start chat directly
|
-- then it is going to start chat directly
|
||||||
@ -1389,7 +1389,7 @@ function npc.step(self, dtime)
|
|||||||
self.texture = {self.selected_texture}
|
self.texture = {self.selected_texture}
|
||||||
self.base_texture = {self.selected_texture}
|
self.base_texture = {self.selected_texture}
|
||||||
self.object:set_properties(self)
|
self.object:set_properties(self)
|
||||||
npc.log("WARNING", "Corrected textures on NPC child "..dump(self.npc_name))
|
--npc.log("WARNING", "Corrected textures on NPC child "..dump(self.npc_name))
|
||||||
-- Set interval to large interval so this code isn't called frequently
|
-- Set interval to large interval so this code isn't called frequently
|
||||||
npc.texture_check.interval = 60
|
npc.texture_check.interval = 60
|
||||||
end
|
end
|
||||||
@ -1476,7 +1476,7 @@ function npc.step(self, dtime)
|
|||||||
time = (time) - (time % 1)
|
time = (time) - (time % 1)
|
||||||
-- Check if there is a schedule entry for this time
|
-- Check if there is a schedule entry for this time
|
||||||
-- Note: Currently only one schedule is supported, for day 0
|
-- Note: Currently only one schedule is supported, for day 0
|
||||||
npc.log("DEBUG_SCHEDULE", "Time: "..dump(time))
|
--npc.log("DEBUG_SCHEDULE", "Time: "..dump(time))
|
||||||
local schedule = self.schedules.generic[0]
|
local schedule = self.schedules.generic[0]
|
||||||
if schedule ~= nil then
|
if schedule ~= nil then
|
||||||
-- Check if schedule for this time exists
|
-- Check if schedule for this time exists
|
||||||
@ -1487,7 +1487,7 @@ function npc.step(self, dtime)
|
|||||||
-- Check if schedule has a check function
|
-- Check if schedule has a check function
|
||||||
if schedule[time][i].check then
|
if schedule[time][i].check then
|
||||||
-- Add parameters for check function and run for first time
|
-- Add parameters for check function and run for first time
|
||||||
npc.log("DEBUG", "NPC "..dump(self.npc_id).." is starting check on "..minetest.pos_to_string(self.object:getpos()))
|
--npc.log("DEBUG", "NPC "..dump(self.npc_id).." is starting check on "..minetest.pos_to_string(self.object:getpos()))
|
||||||
local check_params = schedule[time][i]
|
local check_params = schedule[time][i]
|
||||||
-- Calculates how many times check will be executed
|
-- Calculates how many times check will be executed
|
||||||
local execution_times = check_params.count
|
local execution_times = check_params.count
|
||||||
@ -1509,8 +1509,8 @@ function npc.step(self, dtime)
|
|||||||
-- Enqueue the schedule check
|
-- Enqueue the schedule check
|
||||||
npc.add_schedule_check(self)
|
npc.add_schedule_check(self)
|
||||||
else
|
else
|
||||||
npc.log("DEBUG_SCHEDULE", "Executing schedule entry for NPC "..dump(self.npc_id)..": "
|
--npc.log("DEBUG_SCHEDULE", "Executing schedule entry for NPC "..dump(self.npc_id)..": "
|
||||||
..dump(schedule[time][i]))
|
--..dump(schedule[time][i]))
|
||||||
-- Run usual schedule entry
|
-- Run usual schedule entry
|
||||||
-- Check chance
|
-- Check chance
|
||||||
local execution_chance = math.random(1, 100)
|
local execution_chance = math.random(1, 100)
|
||||||
@ -1545,13 +1545,13 @@ function npc.step(self, dtime)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- TODO: Change to debug
|
-- TODO: Change to debug
|
||||||
npc.log("DEBUG", "Skipping schedule entry for time "..dump(time)..": "..dump(schedule[time][i]))
|
--npc.log("DEBUG", "Skipping schedule entry for time "..dump(time)..": "..dump(schedule[time][i]))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Clear execution queue
|
-- Clear execution queue
|
||||||
self.schedules.temp_executed_queue = {}
|
self.schedules.temp_executed_queue = {}
|
||||||
npc.log("DEBUG", "New action queue: "..dump(self.actions.queue))
|
--npc.log("DEBUG", "New action queue: "..dump(self.actions.queue))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -260,7 +260,7 @@ function npc.occupations.register_occupation(name, def)
|
|||||||
-- Add to the dialogue tags the "occupation name"
|
-- Add to the dialogue tags the "occupation name"
|
||||||
table.insert(dialogue.tags, name)
|
table.insert(dialogue.tags, name)
|
||||||
-- Register dialogue
|
-- Register dialogue
|
||||||
npc.log("INFO", "Registering dialogue for occupation "..dump(name)..": "..dump(dialogue))
|
--npc.log("INFO", "Registering dialogue for occupation "..dump(name)..": "..dump(dialogue))
|
||||||
local key = npc.dialogue.register_dialogue(dialogue)
|
local key = npc.dialogue.register_dialogue(dialogue)
|
||||||
-- Add key to set of dialogue keys
|
-- Add key to set of dialogue keys
|
||||||
table.insert(dialogue_keys, key)
|
table.insert(dialogue_keys, key)
|
||||||
@ -287,7 +287,7 @@ function npc.occupations.register_occupation(name, def)
|
|||||||
-- Save the definition
|
-- Save the definition
|
||||||
npc.occupations.registered_occupations[name] = def
|
npc.occupations.registered_occupations[name] = def
|
||||||
|
|
||||||
npc.log("INFO", "Successfully registered occupation with name: "..dump(name))
|
--npc.log("INFO", "Successfully registered occupation with name: "..dump(name))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This function scans all registered occupations and filter them by
|
-- This function scans all registered occupations and filter them by
|
||||||
@ -345,11 +345,11 @@ function npc.occupations.initialize_occupation_values(self, occupation_name)
|
|||||||
local def = npc.occupations.registered_occupations[occupation_name]
|
local def = npc.occupations.registered_occupations[occupation_name]
|
||||||
|
|
||||||
if not def then
|
if not def then
|
||||||
npc.log("WARNING", "No definition found for occupation name: "..dump(occupation_name))
|
--npc.log("WARNING", "No definition found for occupation name: "..dump(occupation_name))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
npc.log("INFO", "Overriding NPC values using occupation '"..dump(occupation_name).."' values")
|
--npc.log("INFO", "Overriding NPC values using occupation '"..dump(occupation_name).."' values")
|
||||||
|
|
||||||
-- Initialize textures, else it will leave the current textures
|
-- Initialize textures, else it will leave the current textures
|
||||||
if def.textures and table.getn(def.textures) > 0 then
|
if def.textures and table.getn(def.textures) > 0 then
|
||||||
@ -439,7 +439,7 @@ function npc.occupations.initialize_occupation_values(self, occupation_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Initialize properties
|
-- Initialize properties
|
||||||
minetest.log("def.properties: "..dump(def.properties))
|
--minetest.log("def.properties: "..dump(def.properties))
|
||||||
if def.properties then
|
if def.properties then
|
||||||
-- Initialize trader status
|
-- Initialize trader status
|
||||||
if def.properties.initial_trader_status then
|
if def.properties.initial_trader_status then
|
||||||
|
@ -209,7 +209,7 @@ function npc.relationships.get_dialogues_for_gift_item(item_name, dialogue_type,
|
|||||||
if phase ~= nil then
|
if phase ~= nil then
|
||||||
tags[5] = phase
|
tags[5] = phase
|
||||||
end
|
end
|
||||||
npc.log("DEBUG","Searching with tags: "..dump(tags))
|
--npc.log("DEBUG","Searching with tags: "..dump(tags))
|
||||||
|
|
||||||
return npc.dialogue.search_dialogue_by_tags(tags, true)
|
return npc.dialogue.search_dialogue_by_tags(tags, true)
|
||||||
end
|
end
|
||||||
@ -237,7 +237,7 @@ function npc.relationships.get_response_for_disliked_item(item_name, sex)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, #items do
|
for i = 1, #items do
|
||||||
minetest.log(dump(items[i]))
|
--minetest.log(dump(items[i]))
|
||||||
if items[i].item == item_name then
|
if items[i].item == item_name then
|
||||||
--minetest.log("Returning: "..dump(items[i].response))
|
--minetest.log("Returning: "..dump(items[i].response))
|
||||||
return items[i].response
|
return items[i].response
|
||||||
@ -641,7 +641,7 @@ function npc.relationships.receive_gift(self, clicker)
|
|||||||
clicker:set_wielded_item(item)
|
clicker:set_wielded_item(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
npc.log("DEBUG", "NPC: "..dump(self))
|
--npc.log("DEBUG", "NPC: "..dump(self))
|
||||||
-- Reset gift timer
|
-- Reset gift timer
|
||||||
reset_gift_timer(self, clicker_name)
|
reset_gift_timer(self, clicker_name)
|
||||||
return true
|
return true
|
||||||
|
44
spawner.lua
44
spawner.lua
@ -212,8 +212,8 @@ function npc.spawner.determine_npc_occupation(building_type, workplace_nodes, np
|
|||||||
building_type,
|
building_type,
|
||||||
surrounding_buildings_map
|
surrounding_buildings_map
|
||||||
)
|
)
|
||||||
npc.log("DEBUG", "Found occupations: "..dump(occupation_names).."\nfor local building type: "
|
--npc.log("DEBUG", "Found occupations: "..dump(occupation_names).."\nfor local building type: "
|
||||||
..dump(building_type).."\nAnd surrounding building types: "..dump(surrounding_buildings_map))
|
--..dump(building_type).."\nAnd surrounding building types: "..dump(surrounding_buildings_map))
|
||||||
|
|
||||||
-- Insert default occupation into result
|
-- Insert default occupation into result
|
||||||
table.insert(result, {name=npc.occupations.basic_name, node={node_pos={}}})
|
table.insert(result, {name=npc.occupations.basic_name, node={node_pos={}}})
|
||||||
@ -272,10 +272,10 @@ function npc.spawner.determine_npc_occupation(building_type, workplace_nodes, np
|
|||||||
-- used by another NPC, then, use it
|
-- used by another NPC, then, use it
|
||||||
local meta = minetest.get_meta(workplace_nodes[j].node_pos)
|
local meta = minetest.get_meta(workplace_nodes[j].node_pos)
|
||||||
local worker_data = minetest.deserialize(meta:get_string("work_data") or "")
|
local worker_data = minetest.deserialize(meta:get_string("work_data") or "")
|
||||||
npc.log("DEBUG", "Found worker data: "..dump(worker_data))
|
--npc.log("DEBUG", "Found worker data: "..dump(worker_data))
|
||||||
-- If no worker data is found, then create it
|
-- If no worker data is found, then create it
|
||||||
if not worker_data then
|
if not worker_data then
|
||||||
npc.log("INFO", "Found suitable occupation and workplace: "..dump(result))
|
--npc.log("INFO", "Found suitable occupation and workplace: "..dump(result))
|
||||||
table.insert(result, {name=occupation_names[i], node=workplace_nodes[j]})
|
table.insert(result, {name=occupation_names[i], node=workplace_nodes[j]})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -381,7 +381,7 @@ function npc.spawner.spawn_npc_on_plotmarker(pos)
|
|||||||
else
|
else
|
||||||
-- Start another timer to spawn more NPC
|
-- Start another timer to spawn more NPC
|
||||||
local new_delay = math.random(npc.spawner.spawn_delay)
|
local new_delay = math.random(npc.spawner.spawn_delay)
|
||||||
npc.log("INFO", "Spawning one more NPC in "..dump(npc.spawner.spawn_delay).."s")
|
--npc.log("INFO", "Spawning one more NPC in "..dump(npc.spawner.spawn_delay).."s")
|
||||||
timer:start(new_delay)
|
timer:start(new_delay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -404,7 +404,7 @@ function npc.spawner.spawn_npc(pos, area_info, occupation_name, occupation_workp
|
|||||||
-- this is a manually spawned NPC
|
-- this is a manually spawned NPC
|
||||||
local can_spawn = false
|
local can_spawn = false
|
||||||
if npc_count and spawned_npc_count then
|
if npc_count and spawned_npc_count then
|
||||||
npc.log("INFO", "Currently spawned "..dump(spawned_npc_count).." of "..dump(npc_count).." NPCs")
|
--npc.log("INFO", "Currently spawned "..dump(spawned_npc_count).." of "..dump(npc_count).." NPCs")
|
||||||
if spawned_npc_count < npc_count then
|
if spawned_npc_count < npc_count then
|
||||||
can_spawn = true
|
can_spawn = true
|
||||||
end
|
end
|
||||||
@ -429,7 +429,7 @@ function npc.spawner.spawn_npc(pos, area_info, occupation_name, occupation_workp
|
|||||||
npc.initialize(ent, pos, nil, nil, occupation)
|
npc.initialize(ent, pos, nil, nil, occupation)
|
||||||
end
|
end
|
||||||
-- If node_data is present, assign nodes
|
-- If node_data is present, assign nodes
|
||||||
minetest.log("Node data: "..dump(node_data))
|
--minetest.log("Node data: "..dump(node_data))
|
||||||
if node_data then
|
if node_data then
|
||||||
npc.spawner.assign_places(ent:get_luaentity(), entrance, node_data, pos)
|
npc.spawner.assign_places(ent:get_luaentity(), entrance, node_data, pos)
|
||||||
end
|
end
|
||||||
@ -448,7 +448,7 @@ function npc.spawner.spawn_npc(pos, area_info, occupation_name, occupation_workp
|
|||||||
workplace = occupation_workplace_pos,
|
workplace = occupation_workplace_pos,
|
||||||
born_day = minetest.get_day_count()
|
born_day = minetest.get_day_count()
|
||||||
}
|
}
|
||||||
minetest.log("Area info: "..dump(area_info))
|
--minetest.log("Area info: "..dump(area_info))
|
||||||
table.insert(area_info.npcs, entry)
|
table.insert(area_info.npcs, entry)
|
||||||
-- Update and store stats
|
-- Update and store stats
|
||||||
-- Increase total of NPCs for specific sex
|
-- Increase total of NPCs for specific sex
|
||||||
@ -569,9 +569,9 @@ function npc.spawner.assign_places(self, entrance, node_data, pos)
|
|||||||
if #node_data.workplace_type > 0 then
|
if #node_data.workplace_type > 0 then
|
||||||
-- First, find the workplace_node that was marked
|
-- First, find the workplace_node that was marked
|
||||||
for i = 1, #node_data.workplace_type do
|
for i = 1, #node_data.workplace_type do
|
||||||
minetest.log("In assign places: workplace nodes: "..dump(node_data.workplace_type))
|
--minetest.log("In assign places: workplace nodes: "..dump(node_data.workplace_type))
|
||||||
minetest.log("Condition? "..dump(node_data.workplace_type[i].occupation
|
--minetest.log("Condition? "..dump(node_data.workplace_type[i].occupation
|
||||||
and node_data.workplace_type[i].occupation == self.occupation_name))
|
-- and node_data.workplace_type[i].occupation == self.occupation_name))
|
||||||
if node_data.workplace_type[i].occupation
|
if node_data.workplace_type[i].occupation
|
||||||
and node_data.workplace_type[i].occupation == self.occupation_name then
|
and node_data.workplace_type[i].occupation == self.occupation_name then
|
||||||
-- Walkable nodes from occupation
|
-- Walkable nodes from occupation
|
||||||
@ -592,7 +592,7 @@ function npc.spawner.assign_places(self, entrance, node_data, pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
npc.log("DEBUG", "Places for NPC "..self.npc_name..": "..dump(self.places_map))
|
--npc.log("DEBUG", "Places for NPC "..self.npc_name..": "..dump(self.places_map))
|
||||||
|
|
||||||
-- Make NPC go into their house
|
-- Make NPC go into their house
|
||||||
-- If entrance is available let NPC
|
-- If entrance is available let NPC
|
||||||
@ -626,7 +626,7 @@ function npc.spawner.calculate_npc_spawning_on_plotmarker(pos)
|
|||||||
-- Check number of beds
|
-- Check number of beds
|
||||||
local beds_count = #node_data.bed_type--#spawner.filter_first_floor_nodes(node_data.bed_type, pos)
|
local beds_count = #node_data.bed_type--#spawner.filter_first_floor_nodes(node_data.bed_type, pos)
|
||||||
|
|
||||||
npc.log("DEBUG", "Found "..dump(beds_count).." beds in the building at "..minetest.pos_to_string(pos))
|
--npc.log("DEBUG", "Found "..dump(beds_count).." beds in the building at "..minetest.pos_to_string(pos))
|
||||||
local npc_count = 0
|
local npc_count = 0
|
||||||
-- If number of beds is zero or beds/2 is less than one, spawn
|
-- If number of beds is zero or beds/2 is less than one, spawn
|
||||||
-- a single NPC.
|
-- a single NPC.
|
||||||
@ -637,7 +637,7 @@ function npc.spawner.calculate_npc_spawning_on_plotmarker(pos)
|
|||||||
-- Spawn (beds_count/2) NPCs
|
-- Spawn (beds_count/2) NPCs
|
||||||
npc_count = ((beds_count / 2) - ((beds_count / 2) % 1))
|
npc_count = ((beds_count / 2) - ((beds_count / 2) % 1))
|
||||||
end
|
end
|
||||||
npc.log("INFO", "Will spawn "..dump(npc_count).." NPCs at "..minetest.pos_to_string(pos))
|
--npc.log("INFO", "Will spawn "..dump(npc_count).." NPCs at "..minetest.pos_to_string(pos))
|
||||||
-- Store amount of NPCs to spawn
|
-- Store amount of NPCs to spawn
|
||||||
meta:set_int("npc_count", npc_count)
|
meta:set_int("npc_count", npc_count)
|
||||||
-- Store amount of NPCs spawned
|
-- Store amount of NPCs spawned
|
||||||
@ -873,14 +873,14 @@ if minetest.get_modpath("mg_villages") ~= nil then
|
|||||||
--minetest.set_node({x=pos.x,y=pos.y,z=pos.z + (z_sign * z_size)}, {name = "wool:blue"})
|
--minetest.set_node({x=pos.x,y=pos.y,z=pos.z + (z_sign * z_size)}, {name = "wool:blue"})
|
||||||
--minetest.get_meta({x=pos.x,y=pos.y,z=pos.z + (z_sign * z_size)}):set_string("infotext", minetest.get_meta(pos):get_string("infotext")..", Axis: z, Sign: "..dump(z_sign))
|
--minetest.get_meta({x=pos.x,y=pos.y,z=pos.z + (z_sign * z_size)}):set_string("infotext", minetest.get_meta(pos):get_string("infotext")..", Axis: z, Sign: "..dump(z_sign))
|
||||||
|
|
||||||
npc.log("DEBUG", "Start pos: "..minetest.pos_to_string(start_pos))
|
--npc.log("DEBUG", "Start pos: "..minetest.pos_to_string(start_pos))
|
||||||
npc.log("DEBUG", "Plot: "..dump(minetest.get_meta(start_pos):get_string("infotext")))
|
--npc.log("DEBUG", "Plot: "..dump(minetest.get_meta(start_pos):get_string("infotext")))
|
||||||
|
|
||||||
npc.log("DEBUG", "Brotate: "..dump(brotate))
|
--npc.log("DEBUG", "Brotate: "..dump(brotate))
|
||||||
npc.log("DEBUG", "X_sign: "..dump(x_sign))
|
--npc.log("DEBUG", "X_sign: "..dump(x_sign))
|
||||||
npc.log("DEBUG", "X_adj: "..dump(x_sign*x_size))
|
--npc.log("DEBUG", "X_adj: "..dump(x_sign*x_size))
|
||||||
npc.log("DEBUG", "Z_sign: "..dump(z_sign))
|
--npc.log("DEBUG", "Z_sign: "..dump(z_sign))
|
||||||
npc.log("DEBUG", "Z_adj: "..dump(z_sign*z_size))
|
--npc.log("DEBUG", "Z_adj: "..dump(z_sign*z_size))
|
||||||
|
|
||||||
local end_pos = {x=pos.x + (x_sign * x_size), y=pos.y + y_size, z=pos.z + (z_sign * z_size)}
|
local end_pos = {x=pos.x + (x_sign * x_size), y=pos.y + y_size, z=pos.z + (z_sign * z_size)}
|
||||||
|
|
||||||
@ -1099,7 +1099,7 @@ minetest.register_chatcommand("restore_area", {
|
|||||||
privs = {server = true},
|
privs = {server = true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local args = npc.utils.split(param, " ")
|
local args = npc.utils.split(param, " ")
|
||||||
minetest.log("Params: "..dump(args))
|
--minetest.log("Params: "..dump(args))
|
||||||
if #args < 2 then
|
if #args < 2 then
|
||||||
minetest.chat_send_player("Please specify horizontal and vertical radius.")
|
minetest.chat_send_player("Please specify horizontal and vertical radius.")
|
||||||
return
|
return
|
||||||
|
@ -440,7 +440,7 @@ function npc.trade.get_dedicated_trade_offers(self)
|
|||||||
|
|
||||||
local trade_list = self.trader_data.trade_list
|
local trade_list = self.trader_data.trade_list
|
||||||
|
|
||||||
npc.log("INFO", "NPC Inventory: "..dump(self.inventory))
|
--npc.log("INFO", "NPC Inventory: "..dump(self.inventory))
|
||||||
|
|
||||||
for item_name, trade_info in pairs(trade_list) do
|
for item_name, trade_info in pairs(trade_list) do
|
||||||
-- Abort if more than 12 buy or sell offers are made
|
-- Abort if more than 12 buy or sell offers are made
|
||||||
@ -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.
|
-- 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
|
-- Also, avoid creating sell offers immediately if the item was just bought
|
||||||
local item = npc.inventory_contains(self, item_name)
|
local item = npc.inventory_contains(self, item_name)
|
||||||
minetest.log("Searched item: "..dump(item_name))
|
--minetest.log("Searched item: "..dump(item_name))
|
||||||
minetest.log("Found: "..dump(item))
|
--minetest.log("Found: "..dump(item))
|
||||||
if item ~= nil and trade_info.last_offer_type ~= npc.trade.OFFER_BUY then
|
if item ~= nil and trade_info.last_offer_type ~= npc.trade.OFFER_BUY then
|
||||||
-- Check if item can be sold
|
-- Check if item can be sold
|
||||||
if trade_info.item_sold_count == nil
|
if trade_info.item_sold_count == nil
|
||||||
|
Loading…
Reference in New Issue
Block a user