Difference between revisions of "Papyrus FAQs"
Jump to navigation
Jump to search
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> | </pre> | ||
Line 344: | Line 332: | ||
</pre> | </pre> | ||
=== 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()? === | ||
<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> |