So... what's the deal with extending scripts?

Post » Mon Jun 18, 2012 4:47 pm

I still don't get, what extending script is for (the wiki is (by far) not really clear in this point). For me, it kinda does two things at the same time, which is not very welcome for the average scripter. First of all, it defines the type of script, say where you're allowed to use it. Extending ActiveMagicEffect is only allowed in magic effects, Quest is only allowed in quests, etc.
Second, it inherits all functions from its parent, meaning you can use the functions, which are defined in the script you are extending. So if you use the ActiveMagicEffect script, you can only use those functions defined in there, since it is not extending anything. Whereas, in the Object Reference script, you can use functions defined in there as well as functions defined in the Form script.
So in the ActiveMagicEffect script, you can not use all these functions defined elsewhere, except you write Game.GetPlayer() and stuff like that.
Did I got it right so far? That would be kinda annoying always having to check where this or that function is defined and write the appropriate script name in front. And how would the syntax be if you wanna for example address a reference and do sth with it. I am still thinking about the spell I want to create. There already exist ObjectReference scripts doing this: Self.GetCurrentLocation().SetCleared()
If I want to do that in a ActiveMagicEffect script, do I have to write like akCaster.ObjectReference.GetCurrentLocation().Location.SetCleared() ?? This is all very confusing and kinda bloated... Hope, someone with better insight might enlighten me.
User avatar
Sammi Jones
 
Posts: 3407
Joined: Thu Nov 23, 2006 7:59 am

Post » Tue Jun 19, 2012 1:26 am

I've written a bit about this on my website, does this help? http://www.cipscis.com/skyrim/tutorials/externalaccess.aspx

Cipscis
User avatar
Georgine Lee
 
Posts: 3353
Joined: Wed Oct 04, 2006 11:50 am

Post » Tue Jun 19, 2012 4:38 am

your tutorial was quite insightful (I now understood, what casting is for!), though I still don't see any errors in my stuff.
I also tried it with brute force importing. I imported Location and ObjectReference. when I now write
akCaster.GetCurrentLocation()
the script knows where the GetCurrentLocation function is. I saved it in a variable of type Location. Upon calling SetCleared, the script knows where to look for this function and we have the right type of variable. Still, nothing happens. Curiously, calling IsCleared works like a charm out of the box without all this fiddling around (and this is also a function, defined in the Location script...)
User avatar
Lynette Wilson
 
Posts: 3424
Joined: Fri Jul 14, 2006 4:20 pm

Post » Tue Jun 19, 2012 6:26 am

Hmm, could you post the script you're having trouble with? Maybe one of us with fresh eyes will be able to notice something.

Cipscis
User avatar
Matt Terry
 
Posts: 3453
Joined: Sun May 13, 2007 10:58 am

Post » Tue Jun 19, 2012 3:28 am

yeah, right. I forgot.
Scriptname MM_ClearLoc extends ActiveMagicEffect {Clears or unclears Location on Spell use}import Locationimport ObjectReferenceLocation loclocation property fixedloc autoEvent OnEffectStart(Actor akTarget, Actor akCaster)loc=akCaster.GetCurrentLocation()Debug.Messagebox("Caster=" + akCaster + " , current loc=" + loc + " target:" + akTarget)if loc.IsCleared()  Debug.Messagebox("is cleared")  loc.SetCleared(false)else  Debug.Messagebox("is not cleared")  loc.SetCleared(true)endif  fixedloc.SetCleared()EndEvent
I also defined a property as location to see if it gets changed when I put sth in there "by hand", but still... nothing.
User avatar
Charlotte Lloyd-Jones
 
Posts: 3345
Joined: Fri Jun 30, 2006 4:53 pm

Post » Tue Jun 19, 2012 4:55 am

I can't see anything that looks wrong in there. Are there many examples of this being used in the vanilla game that you can compare your script with?

Cipscis
User avatar
Isabella X
 
Posts: 3373
Joined: Sat Dec 02, 2006 3:44 am

Post » Tue Jun 19, 2012 5:38 am

yeah, there is defaultclearlocationonactivate and defaultclearlocationondeath, they are both extending actor or objectreference (not location) and it seems to kinda work....
User avatar
Rex Help
 
Posts: 3380
Joined: Mon Jun 18, 2007 6:52 pm


Return to V - Skyrim