I believe this is an NPC dialogue engine. It doesn't make the NPC move. But if the NPC were walking, you'd need additional code to make sure that you could only talk to it while it was facing you. To tweak for a moving NPC:
switch (npcdir)
{
case "down"
if place_meeting(x,y+4,objlink){
if keyboard_check(ord('X')){
if distance_to_object(objlink)<10{
screen_redraw();
Say("I'm AN NPC BRO!",true,true,true);
}}}
case "up"
if place_meeting(x,y-4,objlink){
if keyboard_check(ord('X')){
if distance_to_object(objlink)<10{
screen_redraw();
Say("I'm AN NPC BRO!",true,true,true);
}}}
case "left"
if place_meeting(x-4,y,objlink){
if keyboard_check(ord('X')){
if distance_to_object(objlink)<10{
screen_redraw();
Say("I'm AN NPC BRO!",true,true,true);
}}}
case "right"
if place_meeting(x+4,y,objlink){
if keyboard_check(ord('X')){
if distance_to_object(objlink)<10{
screen_redraw();
Say("I'm AN NPC BRO!",true,true,true);
}}}
}
That should work for multiple directions, you'd need to declare 'npcdir' in the NPC's movement script so that the program knows the value you're declaring, there are probably a few bugs with this...might want to make a handler for whether or not the player is facing the NPC...I could probably refine this script a bit more, seeing as I only duplicated the script, added a switch and changed a few variables. If anyone wants a refined version, either PM me or post a request in this thread. I'll write a comprehensive NPC engine if anyone needs one.
EDIT: And an explanation of how the whole thing works would go with the engine as well. ;P