Jump to content

Text Replacement


niston

Recommended Posts

- I can for the life of me not figure it out!

 

My code here: https://pastebin.com/GNUTbrWc

 

I attached this script to a quest that has 8 quest aliases of type referencealias, named TR_01 to TR_08. I linked these to the respective script properties in CK.

 

The Form I pass into MSG_01 is a MiscItem with it's name being the Text to show. Apparently this is the way to do it, as using a message supposedly will -for some reason- not work?

 

No matter - All I ever get in game when using <Alias=TR_01> in a Message Box is [...], indicating the Alias is not filled. I set the owning quest of the message box to be the quest that has the script attached.

 

There's this error in the papyrus logs: "error: Cannot call ForceRefTo() on a None object, aborting function call"

 

I expected it to go away when I linked the TR_ properties to the actual TR_ aliases, but the error persists.

 

Also tried restarting the quest after filling MSG_01, using .Stop() and .Start(), but to no avail.

 

 

What am I doing wrong?

Edited by niston
Link to comment
Share on other sites

It is really poorly explained, and a lot easier than it sounds. Try this:

 

(1) Make a new message MYMESSAGE set the quest owner to your quest (say MYQUEST) in the Title Box put [ I Love you ]

 

(2) Make a new Quest ReferenceAlias (or RefCollectionAlias) MYALIAS, set displayname dropdown to MYMESSAGE, [ Uses stored text ] should automatically check, if you want to name to revert to standard when the object is removed from alias check [ Clear Name when Removed ]

 

(3) Anything that you Alias_MYALIAS.ForceRefTo() or .AddRef() if a collection will inherit the name [ I Love you ] and revert when you Alias_MYALIAS.Clear().

 

(4) If you need that text in a document, set the document owning quest to MYQUEST and in the content use <Alias=MYALIAS> which will populate [ I Love you ]

Link to comment
Share on other sites

Well, the idea was to be able to set the actual display text at runtime...

 

From a predefined instance of course. And I don't want to rename an existing object. I want to show "dynamic" text in a messagebox.

 

 

For example, I want to provide a status line that reads "Status: " and then either "OK" or "NOT OK". So I have "Status: <Alias=TR_01>".

 

The TextReplacer is supposed to take in MSG_01 an item (I tried with a message, first) that's named "OK" or an item that's named "NOT OK", based on the status of some other script.

 

It should then fill the Alias TR_01 with whatever form has been passed to MSG_01. But it fails to do so because the Property TR_01 is none.

 

 

There will also be paged text. 5 lines per page. The name of a recipe or an ingredient on each line, to be specific. So I have "Slot 1: <Alias=TR_01> Slot 2: <Alias=TR_02>" etc.

 

MSG_01 shall be the recipe item for slot 1, MSG_02 for slot 2, etc... On page 1, slot 1 is recipe #1. On page 2, slot 1 is recipe #6, On page 3 its #11 etc.

 

You see, this is for a configuration panel, made from Message Boxes. So, dynamic substitution is a must.

 

 

If I set the ReferenceAlias' displayname to <Message> in CK, can I later change that at runtime to <Someothermessage> ? I don't think it's possible, is it?

 

 

Now... what I really don't get is this: Why is the TR_01 property in my script still none, even after assigning the TR_01 alias to it in CK ??? I mean, it can't call ForceRefTo() because the TR_01 property is None. Ok, but when I check in CK, property TR_01 is set to "alias TR_01 on quest F4MS_qestTextReplacer". Right. But how TF can it be none at runtime, then! How is such a thing even possible?! Aliens ????? Does the Alias TR_01 that's been assigned to it not exist? Then why can it even be assigned? And why is it on the Quest Aliases tab? It makes absolutely zero sense to me. Maybe someone can shed a light?

 

Also, can't believe I'm trying for the past 89 hours to print what is essentially a string to a screen, and fail. ahahahaha :sick:

Edited by niston
Link to comment
Share on other sites

OK this gets tedious as you need to set up a s*** load of MYMESSAGE > MYALIAS for each option and use your code logic to assign objects to aliases.
For some structure, I have just this morning CUT a stack of that crap from one of my mods:

If  pPlayerActor.GetLevel() < 5 
	ThisList = pSKK_476GriefersN00b
	ThisName00 = Alias_GrieferN00bName00;N00b suxor boss 
	ThisName01 = Alias_GrieferN00bName01;N00b suxor bro
	ThisName02 = Alias_GrieferN00bName02;N00b suxor ho
	ThisName03 = Alias_GrieferN00bName03;N00b suxor #4
	ThisName04 = Alias_PlaceholderName04
	ThisName05 = Alias_PlaceholderName05
ElseIf  pPlayerActor.GetLevel() < 15 
	ThisList = pSKK_476GriefersScrub
	ThisName00 = Alias_GrieferScrubName00;Scrub t00l boss
	ThisName01 = Alias_GrieferScrubName01;Scrub t00l bro
	ThisName02 = Alias_GrieferScrubName02;Scrub t00l ho
	ThisName03 = Alias_GrieferScrubName03;Scrub t00l #4
	ThisName04 = Alias_PlaceholderName04
	ThisName05 = Alias_PlaceholderName05
ElseIf pPlayerActor.GetLevel() < 25 
	ThisList = pSKK_476GriefersPlat
	ThisName00 = Alias_GrieferPlatName00;Plat traSh boss
	ThisName01 = Alias_GrieferPlatName01;Plat traSh bro
	ThisName02 = Alias_GrieferPlatName02;Plat traSh ho
	ThisName03 = Alias_GrieferPlatName03;Plat traSh #4
	ThisName04 = Alias_PlaceholderName04
	ThisName05 = Alias_PlaceholderName05
Else 
	ThisList = pSKK_476GriefersL33t
	ThisName00 = Alias_GrieferL33tName00;L33t pwnZ boss
	ThisName01 = Alias_GrieferL33tName01;L33t pwnZ bro
	ThisName02 = Alias_GrieferL33tName02;L33t pwnZ ho
	ThisName03 = Alias_GrieferL33tName03;L33t pwnZ #4
	ThisName04 = Alias_GrieferL33tName04;L33t rektUM ;L33t l8r; Ir0k
	ThisName05 = Alias_GrieferL33tName05;HotCock007
EndIf

;generate actors here 

If iCount == 0
	ThisName00.ForceREFTo(ThisActorREF)
Elseif iCount == 1
	ThisName01.ForceREFTo(ThisActorREF)
Elseif iCount == 2
	ThisName02.ForceREFTo(ThisActorREF)
Elseif iCount == 3
	ThisName03.ForceREFTo(ThisActorREF)
Elseif iCount == 4
	ThisName04.ForceREFTo(ThisActorREF)
Elseif iCount == 5
	ThisName05.ForceREFTo(ThisActorREF)
EndIf

 

 

 

edit: spoiler tags !

Edited by SKK50
Link to comment
Share on other sites

Still, I don't get it. Registrator2k does the exact same (create an instance of item with placeatme, then forcerefto an alias via script property to it) in FO4 Hotkeys and it works:

; first
ReferenceAlias Property Slot7_Label Auto
; and
unassignedLabelReference = PlayerREF.PlaceAtMe(HM_UnassignedLabel, 1, False, True, True)
 
; then, later on...
Slot7_Label.ForceRefTo(unassignedLabelReference)
 

My attempt fails, as said, because the script property pointing to the alias is none at runtime. which makes zero sense. because it's not none in CK.

 

So why does it work for FO4 Hotkeys but not for my code? I checked the quests, they look identical. Checked in FO4 that the script properties actually are attached to the quest aliases, and they are.

 

Probably some stupid thing Im missing but I cant figure it out and it's driving me crazy.

 

Oh well, I give up for today.

 

EDIT: But i sent Reg2k a message. maybe he still reads.

Edited by niston
Link to comment
Share on other sites

Meh. I copied the quest from FO4 hotkeys into my esp. Removed everything scripts related in FO4 Edit and then attached my TextReplacer script instead, in CK.

 

It works.

 

I see zero difference between the quest I created in CK and the quest I copied over. While obviously, there must be a difference.

 

"It just works."

 

 

EDIT: After trying to add more aliases to the Quest in CK, the quest broke again and the script property editor went sort of haywire when trying to edit further. For example, it insisted that I had selected an Alias "TR_10" while simultaneously showing Alias "Player" as selected.... Closed CK and edited the quest aliases in Fo4Edit instead. Seems to be fine that way.

 

I think there might be something not 100% right with the quest editor window in CK.

Edited by niston
Link to comment
Share on other sites

  • 2 weeks later...

So I built me a class that abstracts away the most tedious aspects of text replacement by form name and by global variable.

 

If a humble observation is permitted: I once implemented a GUI on a serial 192x64 pixel graphics display (binary protocol over RS232). That was of course a complete PITA, but still rather straight forward compared to working with text in this game. Whoever came up with the convoluted excuse of a system that's in place clearly enjoys their deeply rooted hatred for all of mankind.

Edited by niston
Link to comment
Share on other sites

Looking for a way to dynamically hide or show text, I tried being clever and named a miscitem <Alias=SomeTextReplacementToken>. Trying to print the name of this misc item via another alias does not cause any papyrus error to be written to the logs, but produces a rather unexpected result:

 

 

 

jb7VVu7.jpg

 

 

 

Is there a way to show or hide a line of text in a message somehow?

Edited by niston
Link to comment
Share on other sites

  • Recently Browsing   0 members

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