From afe8dc8f6e4b6ff478194e9ecd9c56c289beec90 Mon Sep 17 00:00:00 2001 From: Zorman2000 Date: Mon, 27 Mar 2017 20:05:18 -0400 Subject: [PATCH] Places: Detect building entrances (WIP) --- actions/places.lua | 30 ++++++++++++++++++++++++++++++ spawner.lua | 13 +++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/actions/places.lua b/actions/places.lua index 89ce5e9..eaae95c 100644 --- a/actions/places.lua +++ b/actions/places.lua @@ -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 diff --git a/spawner.lua b/spawner.lua index 1a871dc..c4f549b 100644 --- a/spawner.lua +++ b/spawner.lua @@ -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