Jump to content

[Tutorial] Accessing External Functions and Properties in Papyrus


Cipscis

Recommended Posts

Hey everyone! Just a notification that I've put a new tutorial up in cipscis.com's Skyrim section, talking about the various ways in which functions and properties need to be accessed. Hopefully some of you will find it useful.

 

Here's a link - Accessing External Functions and Properties in Papyrus

 

As always, any feedback is appreciated.

 

Cipscis

Link to comment
Share on other sites

Nice. I have to say, I think the #2 example on cast referencing is a lot more clear. In particular because

 

LinkedRef = GetLinkedRef() as TeleportOnBleedout

 

and

 

LinkedRef.TeleportAway()

 

is much more readable than:

 

LinkedRef = GetLinkedRef()

 

and

 

(LinkedRef as TeleportOnBleedout).TeleportAway()

 

I mean, you may as well just make the #1 case:

 

(GetLinkedRef() as TeleportOnBleedout).TeleportAway()

 

and save yourself a line of code if you're going to make it that much less readable anyway.

Link to comment
Share on other sites

Thanks :)

 

I agree that it's clearer that way. I think it's easier to think of casting something to a different type as you're receiving it - when it still feels as though it could be "in flux" - than it is to think of casting it to a different type once you already have it - once it's been "set". Particularly if you're not used to the concept of casting.

 

Hopefully having all of those working examples will help anyone unfamiliar with the concept to get their head around it a little bit better.

 

Cipscis

Link to comment
Share on other sites

The thing I can't wrap my head around is that warning in the wiki:

 

Be careful with variables and auto properties on scripts that are extended by other scripts - especially where some script somewhere else may have a property pointing to the base script, or trying to cast to the base script. This is because it would be possible to have two copies of a script attached to the same object, thereby creating two copies of the variable/auto property - and the other scripts that refer to the base script may randomly pick which one to talk to.

 

This is doubly-true of scripts with native functions, as the game can attach these to in-game objects at any time if it needs to, thereby creating another copy of the variable or auto property.

 

I'm not quite sure how or why this sort of thing might come up. :huh:

Link to comment
Share on other sites

  • 4 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...