Difference between revisions of "Papyrus FAQs"

681 bytes added ,  13:59, 11 May 2016
no edit summary
imported>Digitalparanoid
imported>Digitalparanoid
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 304: Line 308:
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 344: Line 332:
</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? ===
<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. ===
 
<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>