Global function not found? Wat?

Post » Sun Jun 24, 2012 11:22 am

OK, in my global variable quest, I defined the following global function:

Float Function DistanceBetween(Objectreference A,ObjectReference B) global ; Returns the distance between 2 objectreferences    return Sqrt((A.Z-B.Z)*(A.Z-B.Z)+((Sqrt((A.X-B.X)*(A.X-B.X)+(A.Y-B.Y)*(A.Y-B.Y)))*(Sqrt((A.X-B.X)*(A.X-B.X)+(A.Y-B.Y)*(A.Y-B.Y)))))endfunction

But in another script, when I try to save, it gives me this error:

FollowObjectTracker.psc(28,14): DistanceBetween is not a function or does not exist

But, (and here's the kicker), if I change the call to Tvar.DistanceBetween (Tvar is the global variable access prefix I defined) I then get THIS error:

FollowObjectTracker.psc(28,19): cannot call the global function DistanceBetween on the variable ::TVar_var, must call it alone or on a type

Ok...so it's definitely a global function, and should therefore be accessable from any script anywhere in my mod...and it's definitely seeing it if I try to call it directly, because it doesn't like doing that with global functions.

So what in the name of Sheggorath is going on? This same function was working in the same script last night...all I did was get rid of a few Debug.Notification() calls...
User avatar
Nany Smith
 
Posts: 3419
Joined: Sat Mar 17, 2007 5:36 pm

Post » Sat Jun 23, 2012 11:33 pm

Has anyone got any clue what's going on here? Global Functions should be, by definition, Global. Why can't my other scripts see this function?
User avatar
Roddy
 
Posts: 3564
Joined: Fri Jun 15, 2007 11:50 pm

Post » Sat Jun 23, 2012 11:47 pm

This won't solve your problem, but why not use the http://www.creationkit.com/GetDistance_-_ObjectReference function instead?

Edit: Also, have your tried preceding your function call with the script name? Something like [script name].[function stuffs]?
User avatar
:)Colleenn
 
Posts: 3461
Joined: Thu Aug 31, 2006 9:03 am

Post » Sun Jun 24, 2012 12:22 am

If you are calling a global function and the function's owning script isn't the current script or isn't http://www.creationkit.com/Script_File_Structure#Imports, then you must prefix it with the name of the script the function resides in.
http://www.creationkit.com/Function_Reference#Calling_Functions
User avatar
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm

Post » Sat Jun 23, 2012 11:33 pm

This won't solve your problem, but why not use the http://www.creationkit.com/GetDistance_-_ObjectReference function instead?

Edit: Also, have your tried preceding your function call with the script name? Something like [script name].[function stuffs]?

Well I wrote this one before I found that one...That's probably in Native Script too, so I bet it's a lot faster...heh...

Don't suppose you've run across anything that gives unit vector information for direction...for examle, if I want to make a model face towards a target location, but I only have coordinates, not rotation information?

I guess "Global" functions aren't really Global, if you have to prefix them with the scriptname...
User avatar
Liii BLATES
 
Posts: 3423
Joined: Tue Aug 22, 2006 10:41 am

Post » Sat Jun 23, 2012 8:52 pm

Well I wrote this one before I found that one...That's probably in Native Script too, so I bet it's a lot faster...heh...

Don't suppose you've run across anything that gives unit vector information for direction...for examle, if I want to make a model face towards a target location, but I only have coordinates, not rotation information?
I think you need some information about the object's rotation. Not entirely sure though, my math is too rusty. Can't you get the object's rotation with the GetAngleX/Y/Z functions?

I guess "Global" functions aren't really Global, if you have to prefix them with the scriptname...
I think a global function in papyrus just means it can be accessed outside that script. Not unlike static functions methods in Java.
User avatar
BethanyRhain
 
Posts: 3434
Joined: Wed Oct 11, 2006 9:50 am

Post » Sun Jun 24, 2012 11:17 am

I think you need some information about the object's rotation. Not entirely sure though, my math is too rusty. Can't you get the object's rotation with the GetAngleX/Y/Z functions?

The object, yes. The target, yes. "What direction do I need to face the object so it is facing the target", no.

I could figure it out with a couple hours looking up the old Trigonometric functions (Since getting an angle isn't simple in 3D...that "GetHeadingAngle(Other)" function won't cut it, since it gives you ONE angle, and I need at least two (I think that one gives you the Z-axis rotation?)

What I'm working on is trying to make a homing missile type spell, so as the target moves, the missile needs to turn toward it.
User avatar
John N
 
Posts: 3458
Joined: Sun Aug 26, 2007 5:11 pm

Post » Sun Jun 24, 2012 7:42 am

I describe what global functions are here - http://www.cipscis.com/skyrim/tutorials/externalaccess.aspx

You're right, "global" is a bit of a misnomer. What it means is that the function doesn't run on an in-game object, so I guess it's running in a "global" context.

Cipscis
User avatar
Natalie Harvey
 
Posts: 3433
Joined: Fri Aug 18, 2006 12:15 pm


Return to V - Skyrim