Signpost script:

Code:
//remove this line if you already have a script file.
import "std.zh"

ffc script sign {
	void run(int m) {
		while(true) {
			while(Link->X < this->X - 8 || Link->X > this->X + 24 || Link->Y < this->Y || Link->Y > this->Y + 24 || Link->Dir != DIR_UP || !Link->InputA) {
				Waitframe();
			}
			Link->InputA = false;
			Screen->Message(m);

			while(Link->X >= this->X - 8 && Link->X <= this->X + 24 && Link->Y >= this->Y && Link->Y <= this->Y + 24 && Link->Dir == DIR_UP) {
				Waitframe();
			}
			
			Screen->Message(0);
		}
	}
}
To use this, give the FFC the number of the string as the first argument. Then, the script will wait until Link is just below the sign, and facing up, and pressing A, and it will display the message.

Tips:

  • It works best with the "Messages freeze all action" and "Messages disappear" rules.
  • You can make the FFC's combo the sign, or you can make it invisible, and place it ontop of an existing sign
  • If you do the former, make sure the combo underneath the FFC is solid, or Link will walk right through it!


-----------------------

NPC script:

Code:
//remove this line if you already have a script file.
import "std.zh"

ffc script real_npc {
	void run(int m, int s, int f, int d, int def_dir) {
		int d_x; 
		int d_y;
		int a_x;
		int a_y;
		int orig_d = this->Data;
		
		if(d == 0) d = 48;
		
		
		while(true) {
			d_x = this->X - Link->X;
			d_y = this->Y - Link->Y;
			a_x = Abs(d_x);
			a_y = Abs(d_y);
			
			if(f != 0) {
				if(a_x < d && a_y < d) {
					if(a_x <= a_y) {
						if(d_y >= 0) {
							this->Data = orig_d + DIR_UP;
						} else {
							this->Data = orig_d + DIR_DOWN;
						}
					} else {
						if(d_x >= 0) {
							this->Data = orig_d + DIR_LEFT;
						} else {
							this->Data = orig_d + DIR_RIGHT;
						}
					}
				} else {
					this->Data = orig_d + def_dir;
				}
			}
			
			if(Link->InputA && a_x < 24 && a_y < 24) {
				if(s != 0) Game->PlaySound(s);
				Link->InputA = false;
				Screen->Message(m);
			}
			Waitframe();
		}
	}
}
Takes 5 parameters (!!):

0: The message. Same as the sign post.
1: S sound to play when activated.
2: Whether to have the NPC turn to face Link when he's near. See below for details. (0 is off, anything else is on)
3: If #2 is on, how close Link must be for the NPC to turn, in pixels (+ 16, because that's how wide Link is) (default is 48)
4: If #2 is on, which direction is the "default" direction, when Link is far away (0 - Up, 1 - Down, 2 - Left, 3 - Right)

To have an NPC that faces Link, you must put the combos for each direction in a certain order: Up, Down, Left, Right, AND! You must set the FFC to the UP facing combo. If you do that, you'll be fine.

Tips:

  • Like the Sign post, you should put a solid combo on the same square as the NPC, so Link can't move through it.
  • If you use the facing feature, then you must use the FFC as a sprite, you can't have it invisible on top of an NPC combo. If you're just using a plain NPC, then it doesn't matter which you do.
  • It works best with the "Messages freeze all action" and "Messages disappear" rules.


Have fun!