Editing Papyrus FAQs

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.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 16: Line 16:
=== To whom do I send fan/hate mail about Papyrus? ===
=== To whom do I send fan/hate mail about Papyrus? ===


[https://community.bethesda.net/people/SmkViper SmkViper] created Papyrus and actively helps scripters in the [https://community.bethesda.net/community/fallout/fallout-4/creation-kit-beta official Fallout 4 Creation Kit forum.]
[https://community.bethesda.net/people/SmkViper SmkViper] created Papyrus and actively helps scripters in the official Fallout 4 Creation Kit forum.


== First Steps ==
== First Steps ==
Line 167: Line 167:
<PapyrusProject xmlns="PapyrusProject.xsd" Flags="Institute_Papyrus_Flags.flg" Output="D:\Steam\steamapps\common\Fallout 4\Data\Scripts" Optimize="true" Release="true" Final="true">   
<PapyrusProject xmlns="PapyrusProject.xsd" Flags="Institute_Papyrus_Flags.flg" Output="D:\Steam\steamapps\common\Fallout 4\Data\Scripts" Optimize="true" Release="true" Final="true">   
   <Imports>   
   <Imports>   
    <Import>D:\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base</Import> 
     <Import>D:\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User</Import>   
     <Import>D:\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User</Import>   
    <Import>D:\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base</Import>   
   </Imports>   
   </Imports>   
   <Scripts>   
   <Scripts>   
    <Script>AutoLoot\Fragments\Terminals\TERM_dubhAutoLootMenuAdvance_0100272C.psc</Script>   
  <Script>AutoLoot\Fragments\Terminals\TERM_dubhAutoLootMenuAdvance_0100272C.psc</Script>   
    ...   
  ...   
   </Scripts>   
   </Scripts>   
</PapyrusProject>
</PapyrusProject>
Line 196: Line 196:
   
   
== Advanced ==
== Advanced ==
=== Are data types distinct? Or are they ultimately floats as in the Oblivion scripting language? ===
In the Oblivion scripting language, bools were integers and integers were floats; the bool and integer data types were therefore clarifying abstractions and ultimately floats. However, in Papyrus, each data type is distinct, but although each data type is distinct, the compiler will automatically cast certain types to other types that are determined to be safe.


=== Are While loops safe to use for persistent or continuous effects? ===
=== Are While loops safe to use for persistent or continuous effects? ===
Line 285: Line 281:
=== Are arrays limited to 128 elements? ===
=== Are arrays limited to 128 elements? ===


* Arrays that are created by scripts via the <code>New</code> operation or <code>Add()</code> function '''are''' limited to 128 elements.
According to SmkViper:
* Arrays returned by native functions, and editor-filled array properties, are '''not''' limited to 128 elements.
<pre>
There is still an internal 128 limit on array items. Attempting to make an array larger than that will spit out an error at runtime.
</pre>


=== How do I create a dynamic array? ===
=== How do I create a dynamic array? ===


Dynamic arrays grow to fit the number of elements.
According to SmkViper:


To create an empty dynamic array, pass <code>0</code> as the size.
<pre>
 
Arrays are now dynamic. To create an empty array, pass 0 as the size. You are
<code>
now allowed to pass in a variable or calculation for an array size, and you can
ObjectReference[] dynamicArray = new ObjectReference[0]
call add and remove on the array to add and remove items.
</code>
</pre>
 
Also:
 
* You can pass in a variable or calculation for the array size.
* You can call <code>Add()</code> and <code>Remove()</code> on the array to add and remove items.


=== How do I create key-value pairs? ===
=== How do I create key-value pairs? ===
Line 311: Line 304:
make one struct variable your key, and the other the value, and then run Find on
make one struct variable your key, and the other the value, and then run Find on
the key. (Unlike maps, duplicates are permitted since it's just an array.)
the key. (Unlike maps, duplicates are permitted since it's just an array.)
</pre>
=== When I call Activate() on a stack of items dropped by the player, only one item in the stack is returned. ===
This is a known issue, but it is unknown whether there will be a fix. If there is a fix, there will be an alternate function.
According to SmkViper:
<pre>
We don't add or change parameters to existing functions after they've been
released (because it would require all scripts using that function to be changed
or recompiled). That's not to say new functions cannot be added, but no promises.
Because of the heavy use of Activate in scripts, I'm very wary of changing its
behavior, but I'll look into it. An alternative solution might be to add an
ActivateAll function instead of "fixing" Activate.
</pre>
</pre>


Line 335: Line 344:
</pre>
</pre>


=== Does the FindAllReferencesWithKeyword function accept a Formlist as a parameter? ===
=== Can structs store arrays, other structs, and var types? Can arrays store arrays? ===
=== Can structs store arrays, other structs, and var types? Can arrays store arrays? ===
According to SmkViper:
<pre>
Structs are intentionally forbidden from storing arrays, other structs, and var
types to eliminate possible sources of circular references.
Arrays cannot store arrays for the same reason (and because it requires more
work on the part of the type syntax).
</pre>
=== Can CallFunction() be used for reflection? ===
=== Can CallFunction() be used for reflection? ===
According to SmkViper:
<pre>
CallFunction is designed for inter-mod communication and does not have type
information as a result. It is very finicky to use and the compiler can't tell
you if you're doing it wrong. It also is going to be more expensive than a
normal function call both in terms of how fast it runs and the amount of memory
used because you're going through the abstraction of a var array. Therefore -
avoid using it unless you absolutely have to. It's there to solve a very
particular problem, not be a general catch-all for reflection.
</pre>
=== How do I use custom events instead of CallFunction()? ===
=== How do I use custom events instead of CallFunction()? ===
 
=== I can't figure out what scripts govern the supply lines! Halp. ===
According to SmkViper:
 
<pre>
You can pass your script as one of the parameters of the custom event and they can call
a function on your script in return to give the value back. The big advantage of custom
events is they can dispatch in parallel, greatly speeding up processing.
</pre>
 
== Troubleshooting ==
 
=== What happens when Papyrus is "overloaded"? ===
 
According to SmkViper:
 
<pre>
The only thing "overloading" the script system will ever do will be to slow down all
script processing. You could theoretically run your system out of memory at some point
but the game would be unplayable long before then.
</pre>
 
=== Does Papyrus affect framerate? Or "drop" function calls? Or "lose" entire scripts? ===
 
No. According to SmkViper:
 
<pre>
Papyrus never affects framerate, nor does it "drop" function calls. It doesn't "drop
scripts" either, whatever the heck that would mean) You wouldn't have an "overload"
problem if it did, because then it would just throw things out instead of slow down,
but that way lies madness - randomly not running function calls is just silly.
</pre>

Please note that all contributions to the Fallout4 CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see FalloutCK: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)