Jump to content

[LE] Alias not being recognized in Alias script (with property added)


sornan

Recommended Posts

Hello guys :smile:

 

This is now the second time I've ran into this, where an Alias property added to an Alias script is Not being recognized in the code, and I had to take the time to hunt down the actual actor themselves as an actor property instead, which is taking way too much time and defeating the purpose of having the Alias's.

 

The situation:

 

PlayerRef is the Alias that has the script in it

Scriptname Fotr_Player_Sleep_A extends ReferenceAlias  


ObjectReference Property XMarkerDreamStart Auto
ObjectReference Property XMarkerGaladriel_1 Auto

Actor Property PlayerRef  Auto  

Actor Property Galadriel  Auto  

Alias Property Galadriel_TestA  Auto  


Event OnInit()	

     RegisterForSleep()

EndEvent



Event OnSleepStart (Float afSleepStartTime, Float afDesiredSleepEndTime)

        ;This line works fine because it uses the actor itself
	Galadriel.MoveTo(XMarkerGaladriel_1)

        ;The below line will cause the script to not compile if uncommented
 	;Galadriel_TestA.MoveTo(XMarkerGaladriel_1)

        PlayerRef.MoveTo(XMarkerDreamStart)	

	;End  the event
	UnregisterForSleep()


EndEvent

(The script is stripped down to just what is needed for the issue here)

 

And I went through this with the PlayerRef as well, as the script would not accept the Alias, and, as you can see above, I had to use the actor itself instead.

 

The commented out Galadriel_TestA.MoveTo(XMarkerGaladriel_1) will fault the script and it will not compile. I had also tried Alias_Galadriel_TestA as the name, I remembered in the tutorial this format was used at times, the script still would not compile.

 

The Alias's are fine as far as I can tell, the quest has just the two of them, and being this script actually works within the PlayerRef Alias I would say indicates the Alias works.

 

 

I welcome any input or help on how to access and use Alias's within the scripts.

Edited by sornan
Link to comment
Share on other sites

You need a ReferenceAlias Property, your script extends "ReferenceAlias", not "Alias".

 

Try this:

 

ReferenceAlias Property Galadriel_TestA Auto

 

then replace your non-compiling function with this:

 

Galadriel_TestA.GetActorReference().MoveTo(XMarkerGaladriel_1)

 

 

https://www.creationkit.com/index.php?title=Quest_Alias_Tab: 99% of the time, we use ReferenceAliases, not Aliases, it's a bit confusing the way it's set in the CK, I know...

Link to comment
Share on other sites

Just to add to that, keep in mind a ReferenceAlias and what it actually references are two different things.

 

Galadriel_TestA.GetActorReference() will make sure that it gets the actual reference as a variable.

 

But, you can also use:

Galadriel_TestA.TryToMoveTo(XMarkerGaladriel_1)

 

This way you don't have to get the reference before moving the object. If you need to get the reference anyways because its used multiple times, I recommend assigning it to a variable, and then just using that to reference the object through out the script.

 

MyVar = Galadriel_TestA.GetActorReference()

 

Then put:

ObjectReference MyVar

 

somewhere at the top so multiple functions inside a script can use it.

Edited by smashballsx88
Link to comment
Share on other sites

You need a ReferenceAlias Property, your script extends "ReferenceAlias", not "Alias".

 

Try this:

 

ReferenceAlias Property Galadriel_TestA Auto

 

then replace your non-compiling function with this:

 

Galadriel_TestA.GetActorReference().MoveTo(XMarkerGaladriel_1)

 

 

https://www.creationkit.com/index.php?title=Quest_Alias_Tab: 99% of the time, we use ReferenceAliases, not Aliases, it's a bit confusing the way it's set in the CK, I know...

 

Thanks Hoamaii :smile:

 

Yes, that helped a ton. It indeed worked.

 

That will save time, as doing the actor approach for whatever reason even with the same actor name put in for the property name, sometimes it would not auto-fill, and not allow a listing of the actors to choose from, so then I had to hunt down the actor at their physical location to get the reference (huge waste of time).

 

Thanks for the link there to the Alias description too. :smile:

 

I converted the entire script over to use the method, and going to change over a few others too.

 

Thanks again, hugely helpful and will save me time in doing more scripted content.

 

 

Just to add to that, keep in mind a ReferenceAlias and what it actually references are two different things.

 

Galadriel_TestA.GetActorReference() will make sure that it gets the actual reference as a variable.

 

But, you can also use:

Galadriel_TestA.TryToMoveTo(XMarkerGaladriel_1)

 

This way you don't have to get the reference before moving the object. If you need to get the reference anyways because its used multiple times, I recommend assigning it to a variable, and then just using that to reference the object through out the script.

 

MyVar = Galadriel_TestA.GetActorReference()

 

Then put:

ObjectReference MyVar

 

somewhere at the top so multiple functions inside a script can use it.

 

 

Nice there :smile:

 

Thank you for revealing the option there to somewhat de-clutter the code.

 

Honestly, both methods seem to essentially clutter the code by one means or another, yet of course as you said, for lengthier scripts that repeatedly use references your method may look cleaner.

 

I am curious, when you assign a variable to the reference, can the variable be the same name as the reference?

 

Example:

Galadriel_TestA = Galadriel_TestA.GetActorReference()

ObjectReference Galadriel_TestA

 

Just wondered, in case it may work, if not then it's not a big deal.. just add Ref or something to the end of the variable name to keep it unique.

Edited by sornan
Link to comment
Share on other sites

 

I am curious, when you assign a variable to the reference, can the variable be the same name as the reference?

 

Example:

Galadriel_TestA = Galadriel_TestA.GetActorReference()

ObjectReference Galadriel_TestA

 

Just wondered, in case it may work, if not then it's not a big deal.. just add Ref or something to the end of the variable name to keep it unique.

Nope it can't - a reference is a variable, and all namings need to be completely unique or else the game will never know which is which!..

 

Within a script though, as long as it's not a property you can rename it whatever you want provided you don't use the same "MyVar" name for 2 different references. Keep in mind it's just a renaming convenience which may spare you to always have to repeat "Galadriel_TestA.GetActorReference()" whenever you want that ReferenceAlias to do something.

 

Stating "MyVar = Galadriel_TestA.GetActorReference()" at the beginning of a script is like telling Papyrus "now whenever I type 'MyVar', we'll both be talking about the same reference". It keeps things tidier in long scripts.

 

But anyway, with the many modders out here, the best way to ensure that all your namings are completely unique is to create your personal naming system. Using your name is a good way to do that.

 

For instance, I prefix all my .esp's and custom folders with "Hoamaii-Something" (then my SleepingBags become "Hoamaii_SleepingBags" for instance, which ensures it cannot be overwritten by some other "sleepingBags" esp's). And in the CK, I also prefix all my forms and refs with an "_H" followed by 2 other letters to remind me which mod that is attached to. All forms and refs for my sleepingBags are prefixed with "_HSB_" (for "Hoamaii Sleeping Bags") followed by whatever describes best the related form, ref, script, quest, spell, armor, etc. DarkFox127 prefixes his with "DF127_". We all do that, it helps a lot finding our mods' assets more easily in the CK.

 

Start now, it's a good habit to take!.. ;)

 

Have fun!

Link to comment
Share on other sites

 

 

I am curious, when you assign a variable to the reference, can the variable be the same name as the reference?

 

Example:

Galadriel_TestA = Galadriel_TestA.GetActorReference()

ObjectReference Galadriel_TestA

 

Just wondered, in case it may work, if not then it's not a big deal.. just add Ref or something to the end of the variable name to keep it unique.

Nope it can't - a reference is a variable, and all namings need to be completely unique or else the game will never know which is which!..

 

Within a script though, as long as it's not a property you can rename it whatever you want provided you don't use the same "MyVar" name for 2 different references. Keep in mind it's just a renaming convenience which may spare you to always have to repeat "Galadriel_TestA.GetActorReference()" whenever you want that ReferenceAlias to do something.

 

Stating "MyVar = Galadriel_TestA.GetActorReference()" at the beginning of a script is like telling Papyrus "now whenever I type 'MyVar', we'll both be talking about the same reference". It keeps things tidier in long scripts.

 

But anyway, with the many modders out here, the best way to ensure that all your namings are completely unique is to create your personal naming system. Using your name is a good way to do that.

 

For instance, I prefix all my .esp's and custom folders with "Hoamaii-Something" (then my SleepingBags become "Hoamaii_SleepingBags" for instance, which ensures it cannot be overwritten by some other "sleepingBags" esp's). And in the CK, I also prefix all my forms and refs with an "_H" followed by 2 other letters to remind me which mod that is attached to. All forms and refs for my sleepingBags are prefixed with "_HSB_" (for "Hoamaii Sleeping Bags") followed by whatever describes best the related form, ref, script, quest, spell, armor, etc. DarkFox127 prefixes his with "DF127_". We all do that, it helps a lot finding our mods' assets more easily in the CK.

 

Start now, it's a good habit to take!.. :wink:

 

Have fun!

 

Gotcha man, thank you for the clarification there :)

 

I hear you on the importance of the naming of things in general to be unique, in a way that would be rare to find identical names in other mods.

 

I also just had a crash course in finding out that script fragments, at least in quest stages, don't like reference alias's much. I had gotten my other scripts cleaned up with the new stuff, and then tried to add a reference alias property to a quest stage script and it literally locked up the script, indicating that I already had another reference of the same name.. which I did indeed, but I could not remove the bugged out new property. I had to redo the entire quest because there was no stopping the script error upon compile attempt, heck even tried deleting the script and making a new one.. the bugged property still was there lol.

 

I am wondering after this experience, do some people just stick with direct references to actors and don't do Alias's in scripts because of potential issues?

Link to comment
Share on other sites

Something to keep in mind for the future: If you add a property to a quest stage fragment that property will be available to all the other stage fragments on that quest.

Reason: the code of each stage fragment is wrapped inside a function on a larger script created by the CK and attached to the quest itself. The properties are placed in the empty state of that script and thus available to all functions (i.e. stage fragments).

Link to comment
Share on other sites

Thank you IsharaMeradin

 

That is good to know, so those properties only have to be added once for all stages in a quest.

 

And I'm going to probably keep using the Reference Alias for most scripts, except for stages, as I would not want it to bug out like it did, and after an hour I could not remove the bugged property and had to redo the particular quest from scratch.

 

Thanks again everyone for the help :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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