Difference between revisions of "AddTextReplacementData - ObjectReference"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>Fatlenin
imported>Fatlenin
Line 48: Line 48:
== See Also ==
== See Also ==
*[[ObjectReference Script]]
*[[ObjectReference Script]]
*[[Text Replacement]] (general text replacement info)
*[http://www.creationkit.com/index.php?title=Text_Replacement Text Replacement] (general text replacement info)

Revision as of 12:52, 17 June 2016

Member of: ObjectReference Script

Adds an association between the given string and the given form for text replacement usage.

Syntax

Function AddTextReplacementData(string asTokenLabel, Form akForm) native

Parameters

  • asTokenLabel: Label for token to be replaced
  • akForm: Form to use to replace token [NOTE: this does NOT work for references]

Return Value

None

Examples

; Store data so <Token.Name=Owner> displays the name of the NPC in OwnerNPC
AddTextReplacementData("Owner", OwnerNPC)

Details

There is a standard text replacement system that utilizes Aliases and Globals attached to Quests (and some common things like time of day spans) to do text replacement for things like books, letters, etc.. You DO NOT need to use any scripting (such as this function) in order to do basic text replacement.

To replace text you have a token and label pair. For example <Alias.Pronoun=QuestGiver> If QuestGiver was a male that tag would be replaced with "he" if female "she." (Here "Alias" is the token and "QuestGiver" is the label.

See: text replacement for general overview of how that works.

Using this script function basically allows you to create your own token label for use with a generic token.

For instance if you wanted to display the name of an Activator named "Widget of Doom" you could make an Activator property named "MyObject" and use that in the AddTextReplacementData call, specifying a lable of "MyObjectLabel"

Activator Property MyObject auto

Event OnInit()
 myTerminal.AddTextReplacementData("MyObjectLabel", MyObject)
EndEvent

Then in that terminal's display text you can use the generic token with the specified label "MyObjectLabel":

Control terminal for <Token.Name=MyObjectLabel>:

Which would print to the terminal screen: "Control terminal for Widget of Doom"

See Also