Sign in to follow this  
Salk

[KotOR] GetNearestObject() / GetNearestObjectByTag() question

Recommended Posts

Hello!

Can someone tell me if any of the function above could be used by an object to return itself?

Ex. heartbeat script for one door:

void main() {

  object oDoor = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF);

  SignalEvent(oDoor,EventUserDefined(20));

}

or

void main() {

  string sDoor = GetTag(OBJECT_SELF)
  object oDoor = GetNearestObjectByTag(sDoor, OBJECT_SELF);

  SignalEvent(oDoor,EventUserDefined(20));

}

The reason I am investigating this as opposed to simply using OBJECT_SELF is that it seems like doors in one area using the same name and sharing the same script don't identify themselves properly.

Share this post


Link to post
Share on other sites

You could use GetNearestObjectToLocation:

// 228: Get the nNth object nearest to lLocation that is of the specified type.
// - nObjectType: OBJECT_TYPE_*
// - lLocation
// - nNth
// * Return value on error: OBJECT_INVALID
object GetNearestObjectToLocation(int nObjectType, location lLocation, int nNth=1);

Another option might be ObjectToString:

// 272: Convert oObject into a hexadecimal string.
string ObjectToString(object oObject);

I think that should be a unique value, but I only ever tried it once and not for use with multiple instances of a single template. Even if it is unique, I suspect it would not be universal across installs, or perhaps even individual sessions on the same machine.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this