Places: Add correct detection of sittable nodes, including stairs used as benches.

Add staircase detection method, for basic staircases. Ability to detect the bottom, middle and top nodes. Useful for future implementation of being able to use 2nd floors.
This commit is contained in:
zorman2000
2017-01-12 19:40:20 -05:00
parent 7e41e328e8
commit e3fc7be783
2 changed files with 115 additions and 16 deletions

21
npc.lua
View File

@ -350,7 +350,7 @@ local function npc_spawn(self, pos)
ent.places_map = {}
-- Temporary initialization of actions for testing
local nodes = npc.places.find_node_nearby(ent, {"cottages:bench"}, 30)
local nodes = npc.places.find_sittable_nodes_nearby(ent.object:getpos(), 5)
minetest.log("Found nodes: "..dump(nodes))
--local path = pathfinder.find_path(ent.object:getpos(), nodes[1], 20)
@ -358,15 +358,16 @@ local function npc_spawn(self, pos)
--npc.add_action(ent, npc.actions.use_door, {self = ent, pos = nodes[1], action = npc.actions.door_action.OPEN})
--npc.add_action(ent, npc.actions.stand, {self = ent})
--npc.add_action(ent, npc.actions.stand, {self = ent})
npc.actions.walk_to_pos(ent, nodes[1], {})
npc.actions.use_sittable(ent, nodes[1], npc.actions.const.sittable.SIT)
npc.add_action(ent, npc.actions.sit, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
npc.actions.use_sittable(ent, nodes[1], npc.actions.const.sittable.GET_UP)
if nodes[1] ~= nil then
npc.actions.walk_to_pos(ent, nodes[1], {})
npc.actions.use_sittable(ent, nodes[1], npc.actions.const.sittable.SIT)
npc.add_action(ent, npc.actions.sit, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
-- npc.add_action(ent, npc.actions.lay, {self = ent})
npc.actions.use_sittable(ent, nodes[1], npc.actions.const.sittable.GET_UP)
end
-- npc.add_action(ent, npc.action.stand, {self = ent})
-- npc.add_action(ent, npc.action.stand, {self = ent})
-- npc.add_action(ent, npc.action.walk_step, {self = ent, dir = npc.direction.east})