Aller au contenu

Photo

Issues accessing a location's variables


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
Ckrauser

Ckrauser
  • Members
  • 12 messages

I am trying to manipulate a location's field, but keep getting errors. The compiler throws an error when I try to manipulate a vector given a location

location crate_1_loc = GetLocation(GetObjectByTag("crate_1"));
crate_1_loc.vPosition.x += 1.0; // This is not valid

The error is:

ERROR: LEFT OF STRUCTURE PART NOT STRUCTURE

 

I noticed on the NWNwiki and the NWN lexicon, they specifically say that the vector can be manipulated using the dot operator, but it doesn't say whether it's possible for a location. I can take the long way around by getting the object's vector, manipulating that, then creating a location from there; but I was curious if using the dot operator on a location is even possible.



#2
Shadooow

Shadooow
  • Members
  • 4 471 messages

location crate_1_loc = GetLocation(GetObjectByTag("crate_1"));

vector v = GetPositionFromLocation(crate_1_loc);
v.x += 1.0;

crate_1_loc = Location(GetAreaFromLocation(crate_1_loc),v,GetFacingFromLocation(crate_1_loc));

 

etc.

 

could be wrote differently but now you see whats needed



#3
Proleric

Proleric
  • Members
  • 2 361 messages

To the best of my knowledge, you have to go the long way round, using GetPositionFromLocation to extract the vector, and the Location function to build the new location from the modified vector.

 

The vector structure certainly has fields .x .y and .z of type float. I don't think the location structure format has been published, nor is it trivial to deduce the field names. I imagine it might well contain a field of type vector.

 

Incidentally, if anyone does know the format of the internal structures, it would be useful to know.

 

EDIT : What Shadooow said.



#4
Ckrauser

Ckrauser
  • Members
  • 12 messages

Hmm ok thanks for the replies. I would assume it could be accessed, but as you said it's not something that can be deduced very easily. I've tried the obvious variations on vPosition, but none of them work. I'm using code similar to what Shadooow posted and it works fine, so I'll stick with that for the time being.



#5
henesua

henesua
  • Members
  • 3 882 messages

Location is a custom struct with different data types buried within it. NWN has a few of these and you need to access them using the functions provided with the script engine. So with location you need to extract the three pieces of data (each a different type) and then work with them independently. Then you use the Location function to plug them all back in again.


  • Squatting Monk aime ceci