Question how to write GetPos

Post » Fri Sep 19, 2014 9:31 am

I'm trying to write a script using GetPos. The script is supposed to get the x,y,z,angle and cellname of an NPC (Ajira for test purposes) and display them on screen. I'm using MWEdit to compile the script because the script has some MWSE functions in it. It won't compile, and it's not clear to me why. MWEdit gives an error message. "Unknown object ID "Ajira" found!" referencing the line 'set NPCx to "Ajira"->GetPos, x' I have tried a variation or two of that line but still get an error. The MWSE code to display Ajira's cell ID does work and displays it in game. When I get this working, my next step will be to pass (right term?) those values to xPositionCell to move my player character to where Ajira is.

I'm stumped. My original attempt was based on what I saw in the examples in Morrowind Scripting for Dummies and on what I've read in various threads in this forum. However, once I tried to find and fix the error, I noticed that there is a wide variation in how GetPos is written in the examples but no explanation I've seen to say why it is written one way or the other. I find it confusing. A comma between the function name GetPos and the axis argument is there in some examples and missing in others.
pleyer -> GetPos X
player -> GetPos, X
npc_objectID -> GetPos, x
npc_objectID -> GetPos x
"npc_objectID" -> GetPos, X

I have also read one or two suggestions that GetPos should be done on one line and not be split into multiple lines, one line for each axis due to concern that the engine would have problems, but all the examples using GetPos show it being split being done one axis at a time.

What am I overlooking here?

Thanks.

The script itself

Spoiler
Begin JH_sendmethere

;script to move my character to where another NPC is
;uses xPositionCell
;concept - get x,y,z, cellname coordinates of the other NPC
;plug those values into variable names for use in xPositionCell
;send my char to where the NPC is
;MWSE manual gave one suggestion - use xGetRef, getPos and xMyCellID
;Scripting for Dummies describes two functions GetPos and GetAngle
;for script testing, will choose the NPC Ajira



Long Ajiraref ;variable for pointer to Ajira uses xGetRef

float NPCx ;x axis coordinate of the NPC (Ajira)
float NPCy ;y axis coordinate of the NPC (Ajira)
float NPCz ;z axis coordinate of the NPC (Ajira)
float NPCangle ;where looks at the NPC (Ajira), will set as 0
Long WhereAjira ;name of cell object is in - uses xMyCellID


Setx AjiraRef to xGetRef, "Ajira"

;set NPCx to Ajiraref->GetPos, X ;generates an error
;set NPCy to Ajiraref->GetPos, Y
;set NPCz to Ajiraref->GetPos, Z
;set NPCangle to Ajiraref->GetAngle, Z

;set NPCx to Ajira->GetPos, x ;vanilla script unknown object
set NPCx to Ajira->GetPos x ;vanilla script unknown ID found

setx WhereAjira to Ajiraref->xMyCellID

;display to confirm that script works so far
;xMessageFix "Ajira coordinates are %.0f, %.0f, %.0f, %.0f, %s" NPCx, NPCy, NPCz, NPCangle, WhereAjira
xMessageFix "Ajira coordinates are %.0f, %.0f, %.0f, %.0f" NPCx, NPCy, NPCz, NPCangle
;xMessageFix "Ajira cell is %s" WhereAjira
MessageBox "abcdefghijklmnopqrstuvqxyz0123456789abcdefghijk"



End

User avatar
-__^
 
Posts: 3420
Joined: Mon Nov 20, 2006 4:48 pm

Return to III - Morrowind