Make NPC face a point

Hi people, I need some help with a mod I’m making. Basicly I need to tell an NPC to face a certain point or angle. I’ve been reading a lot about Schedules and Tasks, but I couldn’t find a solution.

I know that I can do this to make an NPC move to a certain position:


I can also use this to make them look at another entity:


However, I couldn’t find a Schedule that makes an NPC face the last memorized position. There’s a task named TASK_FACE_LASTPOSITION that apparently does what I need, but I don’t know how to tell an NPC to use it. I tried npc:StartEngineTask(task,data), but it only takes numbers, not names, and I couldn’t find the ID of the task I want to use. Also, I tried it with different numbers but it doesn’t seem to do anything. Any ideas?

full code?

Full code of what? I’m asking how to do something ._. I haven’t done it yet. But if it helps, here’s what I have right now:

local function investigate(npc, pos, run, nearest)
	-- Ignore the "nearest" parameter, its old stuff
	if npc.invdelay > CurTime() then return end
	npc.invdelay = CurTime() + 2 -- A little delay so NPCs don't get stuck recalculating path every tick.
	if npc.investigating == false then
		npc.initpos = npc:GetPos()
		-- Broadcast caution effect
		umsg.Start( "NPCEffect" )
			umsg.Entity( npc )
			umsg.String( "caution" )
		npc.investigating = true
	npc.targetpos = pos
	if run == false and npc.running == false then
		npc:SetSchedule( SCHED_FORCED_GO )
		npc:SetSchedule( SCHED_FORCED_GO_RUN )
		npc.running = true

And then I have a timer that checks if NPCs have arrived their destination

if #npctable > 0 then
	SetGlobalBool("BadNPCOnMap", true)
	for k, v in pairs(npctable) do
		if v.investigating and v.investigating == true and v:GetPos():Distance(v.targetpos)<50 then
			v.investigating = false
			v.targetpos = nil
			v.running = false
			v:SetSchedule( 1 ) -- Idle schedule
			timer.Simple(1, function()
				if IsValid(v) then
					v:SetSchedule( SCHED_ALERT_SCAN  ) -- Turn back 180° and then look forward again
					timer.Simple(3, function()
						if IsValid(v) then
							v:SetSchedule( SCHED_FORCED_GO_RUN ) -- After 3 seconds return to his original position
			-- Broadcast alert effect
			--umsg.Start( "NPCEffect" )
			--	umsg.Entity( v )
			--	umsg.String( "caution" )
	SetGlobalBool("BadNPCOnMap", false)

After they return to their original position, I want them to look at their original angles too. But I can’t find a schedule that does that. Any ideas?

first of all:

Yeah, I use Net library in my mod too, but I used global bools and user messages before knowing about it. I have to tidy up my code, it’s a complete mess. This is the first thing I make in LUA. I took the source of an old mod (with permission of the creator) and modified it to add new features. I’m still learning, thats why the code has some old things I have to replace.

Nevermind. I found that I can use SetAngles with the NPC, although I’ll have to use an incrementing variable to make it look smooth.