Jump to content

[Skyrim][Papyrus][TES5edit] Dynamically filling a ReferenceAlias


hurtifrej

Recommended Posts

Posted

Hello!


I am trying to dynamically fill a ReferenceAlias with an actor so that I can apply a script on the alias, but I cannot get it to work

 

The relevant Papyrus code:


 

ReferenceAlias property game_actor0 auto hidden

sslActorAlias[] partners ;<--- This is not empty, I have checked

game_actor0.ForceRefTo(partners[0].GetReference())
(game_actor0 as GameActorAlias).testInt = 1

Debug.Notification("GameScript.Setup: Done " + (game_actor0 as GameActorAlias).testInt as string)
                               ; ^--- testInt is still 0 here (so game_actor0 is probably none?

 

The relevant ESP structure is as following:


 

Game1Quest

VMAD
	Scripts
		GameScript
			Property 
				Object Union
					FormID: Game1Quest
					Alias 000 game_actor0
	Aliases
		Alias
			FormID: Game1Guest
			Alias 000 game_actor0
			AliasScript GameActorAlias
Aliases
	Alias #0
		Alias Name: game_actor0
		Flags: Optional, Allow Reuse in Quest

 

I have looked at several other mods with similar structure and I cannot for the life of me find what I am missing

This seems like it should be such a trivial thing to do...

 

Posted
59 minutes ago, hurtifrej said:
GameActorAlias

 

Unfamiliar with that, and it doesn't apear in the papyrus index.  I do this all the time and usually use something like the following:

 

Actor Target = partners[0]

 

If Target

   game_actor0.ForceRefTo(Target)

   string sTarget = Target.GetDisplayName()

   Debug.Notification("Target is filled with "+sTarget+".")

Else

   Debug.Notification("Shit be fucked up.")

EndIf

 

Posted
5 hours ago, Seijin8 said:

Unfamiliar with that, and it doesn't apear in the papyrus index.  I do this all the time and usually use something like the following:

 

My bad, I added it in the description now. It is the ReferenceAlias script which I want to hold the data (currently it is just empty apart from one property testInt)

 

Thank you for your help, I tried your suggestion!

 

One potential problem seems to have been me using

game_actor0.ForceRefTo(partners[0].GetReference())

As the function ForceRefTo should take an object? If so I must say the creation kit wiki confused me as it states:

 

Function ForceRefTo(ObjectReference akNewRef)

And the papyrus compiled did not complain about passing the output from ObjectReference Function GetReference()  into ForceRefTo

 

Anyway... the results:


 

;Actor target = partners[0].GetActorRef()
;IF target
;    string sTarget = Target.GetDisplayName()
;    game_actor0.ForceRefTo(target);
;    Debug.Notification("Target is filled with "+sTarget) ;<--- This fires with the correct name
;Else
;    Debug.Notification("Shit be fucked up")
;EndIf


Actor target = partners[0].GetActorRef()
game_actor0.ForceRefTo(target)
If game_actor0
    string sTarget = game_actor0.GetActorRef().GetDisplayName()
    Debug.Notification("game_actor0 is filled with "+sTarget)
Else
    Debug.Notification("Shit be fucked up"); <--- However, when trying to use the ReferenceAlias
					   ; game_actor0, we get this message
EndIf

 

I can access the actor, it is not none...

If the ForceRefTo is successful, then why is game_actor0 false?
 

Posted
3 hours ago, hurtifrej said:

My bad, I added it in the description now. It is the ReferenceAlias script which I want to hold the data (currently it is just empty apart from one property testInt)

 

Thank you for your help, I tried your suggestion!

 

One potential problem seems to have been me using

game_actor0.ForceRefTo(partners[0].GetReference())

As the function ForceRefTo should take an object? If so I must say the creation kit wiki confused me as it states:

 

Function ForceRefTo(ObjectReference akNewRef)

And the papyrus compiled did not complain about passing the output from ObjectReference Function GetReference()  into ForceRefTo

 

Anyway... the results:


 

;Actor target = partners[0].GetActorRef()
;IF target
;    string sTarget = Target.GetDisplayName()
;    game_actor0.ForceRefTo(target);
;    Debug.Notification("Target is filled with "+sTarget) ;<--- This fires with the correct name
;Else
;    Debug.Notification("Shit be fucked up")
;EndIf


Actor target = partners[0].GetActorRef()
game_actor0.ForceRefTo(target)
If game_actor0
    string sTarget = game_actor0.GetActorRef().GetDisplayName()
    Debug.Notification("game_actor0 is filled with "+sTarget)
Else
    Debug.Notification("Shit be fucked up"); <--- However, when trying to use the ReferenceAlias
					   ; game_actor0, we get this message
EndIf

 

I can access the actor, it is not none...

If the ForceRefTo is successful, then why is game_actor0 false?
 

 

Good question. My best guess is that because filling an alias isn't instant (there's the bridge between the quest and the scripting language; they aren't tightly bound), maybe the code is getting ahead of the game.

 

Otherwise, I have no idea.  Honestly, most of the time with papyrus, I make 3 or 4 versions of the code, all accessing in different ways, see which of them takes (though technically they all should, often some don't) and just use whatever worked.  The papyrus language is -- to put it plainly -- quite shit.  The designer intended it only for minimal tasks, and the average Sexlab game environment throws a hell of a lot of stuff through the papyrus bottleneck.

 

Anyway, papyrus often does the unexpected and I find this especially true with aliases.

 

Something that may help would be "sqv" in the console ("see quest variables", I guess), so that you can see exactly what the quest is looking at.  So if the quest name is "AliasFillQuest", then type "sqv aliasfillquest" and it'll show the current state of everything in there.

 

If the code is outrunning the quest, you may be able to verify it is working as intended that way.

 

Posted
9 hours ago, Seijin8 said:

Good question. My best guess is that because filling an alias isn't instant (there's the bridge between the quest and the scripting language; they aren't tightly bound), maybe the code is getting ahead of the game.

 

Otherwise, I have no idea.

 

 

Well, I tried this:

 

string sTarget = ""
Utility.Wait(1.0)
sTarget = game_actor0.GetActorRef().GetDisplayName()
Debug.Notification("1 game_actor0 is filled with "+sTarget)
Utility.Wait(1.0)
sTarget = game_actor0.GetActorRef().GetDisplayName()
Debug.Notification("2 game_actor0 is filled with "+sTarget)
Utility.Wait(1.0)
sTarget = game_actor0.GetActorRef().GetDisplayName()
Debug.Notification("3 game_actor0 is filled with "+sTarget)

 

And they all failed. If it takes more than 3 seconds on average to get it working then that is unsuitable for my purposes.

(Note: if the notifications are identical they seem to be skipped, hence the number at the start)

 

Instead I've created 5 new quests which will hold the data associated with the (up to 5) actors and I will associate it myself in the script... It's a shame because I assumed that holding data associated with Actors is exactly what ReferenceAlias was meant to do. Oh well, if it works it doesn't have to be pretty I guess...

 

Thanks for the help though!

Posted
2 hours ago, hurtifrej said:

And they all failed. If it takes more than 3 seconds on average to get it working then that is unsuitable for my purposes.

 

That definitely isn't right.  When I said not instant, I meant well under a half second.

 

I'm curious though:  returning to my original version that you commented out, you said it appeared to fill correctly.  If so and everything being equal, then it would seem using a bool on the "game_actor0" was returning false.  I've never tried using a referencealias that way, only ever an actor.

Posted
8 hours ago, Seijin8 said:

 

That definitely isn't right.  When I said not instant, I meant well under a half second.

 

I'm curious though:  returning to my original version that you commented out, you said it appeared to fill correctly.  If so and everything being equal, then it would seem using a bool on the "game_actor0" was returning false.  I've never tried using a referencealias that way, only ever an actor.

 

Well I don't know what to tell you ¯\_(ツ)_/¯ that code still uses the same game_actor0.ForceRefTo(target), so even if Papyrus can't interpret a ReferenceAlias as a bool correctly, then

 

sTarget = game_actor0.GetActorRef().GetDisplayName()
Debug.Notification("1 game_actor0 is filled with "+sTarget)

 

should still give the correct output if game_actor0 is filled, right?

 

I suspect the problem is something to do with how I've set up the Quest in my esp. Most problems I encounter are due to not being able to link in-game objects to the script code and the tutorials I find on the subject rarely go into exact detail of what values need to be entered where so I have to try and copy from existing mods.

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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