Open main menu
Home
Random
Log in
Settings
About the CreationKit Wiki
Disclaimers
the CreationKit Wiki
Search
Editing
Papyrus Introduction
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=Setting Variables and Properties= There is one basic way to set a variable, and two basic ways to set properties. Assigning values in a script, and assigning data to a property in the editor. ==Setting variables and properties in the script== The way to set a variable and one of the ways to set a property is to [[Operator_Reference#Assignment_Operators| assign it a value]] in the script itself. You can declare it one place, and set it some place else: <syntaxhighlight lang="papyrus"> ;At the top of the script we declared a variable: Int MyStage ;... ;Later, inside an event block: MyStage = 100 </syntaxhighlight> Or you can assign it at the time you declare it: <syntaxhighlight lang="papyrus"> Int MyStage = 100 </syntaxhighlight> Note: you can set variables and properties when you declare them ''everywhere in the script'' as long as their type is a "[[Literals_Reference|Literal]]." However variables/properties of all other types (an actor for example) can be set when declared, only if declared inside a function or event. For example, declaring at top, and setting elsewhere: <syntaxhighlight lang="papyrus"> ;Delcared at top ObjectReference ThingActivatingMe ;set inside an event Event OnActivate(ObjectReference akActionRef) ThingActivatingMe = akActionRef EndEvent </syntaxhighlight> You might do the above if you wanted to hang onto the thing that activated the object for longer than the one instance of the activation. Or you could declare it and set at the same time (inside a function or event) like this: <syntaxhighlight lang="papyrus"> ;set inside an event Event OnActivate(ObjectReference akActionRef) ObjectReference ThingActivatingMe = akActionRef EndEvent </syntaxhighlight> For a more detailed discussion of how to declare and set variables and properties, see: [[Variables and Properties (Papyrus)| Variables and Properties]] ==Setting Property Data in the Editor== The other way is to assign a property by pointing to an object in the editor, or typing in the value in the editor. This is how we might set the MyQuest and StageToSet property in the example script we were looking at earlier. Many forms in the editor have a "Scripts Tab" that allows you to a) add scripts to the object, and b) set the values of properties on those scripts. For now, let's look at an Activator form in the editor, and look at its script area: If you select the script by clicking it, then click the properties button, you will see a list of all the properties. If you click the "Edit Value" button and edit field will appear either a text field to enter a numeric data, checkbox if it's a bool, or one or more drop down if it's an object. In the above image you can see that myQuest has been set to MQ101, and StageToSet has been set to 100. <gallery> File:MyTriggerBoxScriptEx.jpg|Accessing Script Properties on an Activator Base Object File:MyTriggerBoxScriptPropertiesEx.jpg|Viewing and Setting properties </gallery> ==References Inheriting scripts and property values from parent base objects== [[Image:ReferenceScriptPropertyEx.jpg|thumb|600px|Accessing the Scripts Tab on a Reference]] [[Reference|References]] inherit any scripts and property settings from their [[Base Object]]s (as listed in the [[Object Window]]). For example, [[:Category:Actor|Actors]] and [[Activator|Activators]]. If you attach a script to an Actor or an Activator all of the individual [[Reference|references]] of those objects in the game will also have those same scripts. Their references will also inherit the data on any properties you have set on their scripts. You can override these properties by opening the "Scripts Tab" on the [[reference]] in the [[Render Window]], and set property data that you want to override on the [[reference]] itself. You can also remove the inherited script altogether from the reference, by removing the script from the reference's scripts tab in the render window. Note: you can also add scripts directly to the [[reference]] in the [[Render Window]] as well.
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)