Places: Detect building entrances (WIP)

This commit is contained in:
Zorman2000 2017-03-27 20:05:18 -04:00
parent d375762d11
commit afe8dc8f6e
2 changed files with 41 additions and 2 deletions

View File

@ -131,6 +131,36 @@ function npc.places.find_node_in_area(start_pos, end_pos, type)
return nodes
end
-- Specialized function to find doors that are an entrance to a building.
-- The criteria for an entrance door is the following:
-- - Node in front and above door is air, or
-- - Node two nodes from front of door and above door is air and,
-- - Up to two nodes above is air
-- This needs to be fine-tuned with more practical scenarios.
-- The given position is assumed to be the openable node's lower node
-- (in the case of doors which have two-node heights)
function npc.places.openable_node_is_entrance(pos)
local result = false
-- Calculate the first position to check
-- Need to get the direction of the openable node
local node = minetest.get_node(pos)
local x_adj = 0
local z_adj = 0
if node.param2 then
if node.param2 == 0 then
elseif node.param2 == 1 then
elseif node.param2 == 2 then
elseif node.param2 == 3 then
end
end
--local first_check_pos = {x=, y=, z=}
end
-- Specialized function to find all sittable nodes supported by the
-- mod, namely default stairs and cottages' benches. Since not all
-- stairs nodes placed aren't meant to simulate benches, this function

View File

@ -58,8 +58,8 @@ npc.spawner.spawn_delay = 10
npc.spawner.spawn_data = {
status = {
"dead" = 0,
"alive" = 1
["dead"] = 0,
["alive"] = 1
}
}
@ -109,6 +109,15 @@ end
-- This function will assign places to every NPC that belongs to a specific
-- house/building. It will use the resources of the house and give them
-- until there's no more. Call this function after NPCs are initialized
-- The basic assumption:
-- - Use only items that are up to y+3 (first floor of building) for now
-- - Tell the NPC where the furnaces are
-- - Assign a unique bed to the NPC
-- - If there are as many chests as beds, assign one to a NPC
-- - Else, just let the NPC know one of the chests, but not to be owned
-- - If there are as many benches as beds, assign one to a NPC
-- - Else, just let the NPC know one of the benches, but not own them
-- - Let the NPC know all doors to the house. Identify the front one as the entrance
function spawner.assign_places(pos, self)
end