TSMDude wrote...
void main()
{
object oCoach = GetObjectByTag("COACH");
object oDriver = GetObjectByTag("DRIVER");
object oArea = GetArea(oCoach);
string sName = GetName(oArea);
if(GetEnteringObject() == oCoach)
{
AssignCommand(oDriver, SpeakString("We've arrived at " + sName + "!"));
}
}
I hope you don't take my comments her the wrong way. This script is just a little wastfull, so thought i would comment on it.
This script fires every time somthing enters the module. And here is my paraphrase on what I see it doing.
OOch, Something just steped on me.
Where is my to do list for this again.
Oh here it is.
1 object oCoach = GetObjectByTag("COACH");
Ok everyone hod on a bit I need to search the entire face of the planet and figure out where the Coach is.
( after looking at sever hundred object if not thousnad) O found it.
2. object oDriver = GetObjectByTag("DRIVER");
O-boy I get to scry the face of the planet again looking for its Driver.
( Fast sucker a few milliseconds later) Ok found it too.
3. object oArea = GetArea(oCoach);
Hay Coach what area are you in.
Coach: I'm in area 42.
4. string sName = GetName(oArea);
That is nice do you happen to have the name of the area.
Sure it is name is. "Way the heck out here".
5 if(GetEnteringObject() == oCoach)
Hay coach did you jusr roll over me ?
coach: Are you kidding!! Im leagues away from you.
Ok Im going back to sleep then.
....
OOch, Something just steped on me.
Let see where is that coach and driver again.
...
**************
Would it not be better to:
void main()
{
object oCoach = GetEnteringObject();
if ( GetTag(oCoach) != "COACH") return;
object oDriver = GetNearestObjectByTag("DRIVER");// Does not search the entire world.
string sName = GetName(GetArea(oCoach));
AssignCommand(oDriver, SpeakString("We've arrived at " + sName + "!"));
}
Paraphrase.
Ouch.
1 object oCoach = GetEnteringObject();
Hay man you just stepped on me.
2 if ( GetTag(oCoach) != "COACH") return;
Are you the Coach, No Then let me sleep...
.
ouch.
1 object oCoach = GetEnteringObject();
Hay that wheel hurts. Carfull Im taking names.
2 if ( GetTag(oCoach) != "COACH") return;
Hay man I have been wating for you.
3. object oDriver = GetNearestObjectByTag("DRIVER");
I needed to talk to your driver.
4 string sName = GetName(GetArea(oCoach));
What is the name of this area again.
5 AssignCommand(oDriver, SpeakString("We've arrived at " + sName + "!"));
Hay driver I was tolt to remind yoou to anounce your arivial in sName.
****
Hope you dont mind may paraphrasing here.
I have just noticed way to many people lately insisting on searching the entire module for an object, when all they care about is the one that just stepped on them.
This method also has the advantage of being able to handle more then one coach and driver in the module. With the first script you would never know if the coach you just searched for and found was the one that just stepped on you or not.
And yes I do know that you where just modifing a script that someone else wrote.
It was just a short enough example that I could not resist.