View Single Post
Old 04-18-2011, 01:22 AM   #8
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by Dak Drexl View Post
Thanks a lot for this tut, but I just want to point out that in the script there is a problem:

Code:
// ST: st_startstore.nss

void main() 
{
	object oStore = GetObjectByTag("TAG_OF_STORE_HERE");
        object oSpeaker = GetPCSpeaker();
	
	if (!GetIsObjectValid(oStore))
		oStore = CreateObject(OBJECT_TYPE_STORE, "RESREF_OF_STORE_HERE", GetLocation(OBJECT_SELF));

	if (GetIsObjectValid(oStore))
		DelayCommand(0.5, OpenStore(oStore, oSpeaker));
}
That exclamation point needs to come out if you want the script to work. It will still compile with it in, but it won't work unless you take it out; just a future warning to anyone!

But thanks again for this very helpful.
Uh, no. The exclamation point is a negation operator. It makes the script create the store object if it does not already exist. If you remove the negation operator you'll spawn a new instance of the store object every time you talk to the merchant, instead of using the one that you already spawned the first time you talked to them. You'd flood the samegame with store object instances if it's a frequently visited merchant.

If you remove the negation operator you'd spawn the store object when an object with that tag already exists. So if your variant "works" it would mean that you've specified the tag of another non-store object within that area that already exists (and your store likely has the same tag as such an object). Change the tag of your store to something unique and it should work.

stoffe is offline   you may: quote & reply,