Editing
Complete Example Scripts
(section)
Jump to navigation
Jump to search
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!
=Usage of Arrays to Make Scripts Compact= In this example you can see how to use a simple script property to reduce the number of scripts you need to write and thus the amount of properties you need to set, which can be time-consuming. Below I was having to do things to about 30 different draugrs: * turn their AI on and make them visible * turn their AI off and make them invisible I have different conditions within my level for when each of these two actions should occur. I could divide this into two scripts, but instead I wrote one script and passed a property to the script with each instance of the script to determine which aspect of the script would run. <syntaxhighlight lang="papyrus"> Actor Property PlayerREF Auto Actor[] Property DraugrArray Auto ; Contains 30 elements filled in CK with the 30 Draugr Bool Property bEnableBeasts Auto ; Can be set from another script and/or initialized true or false Event OnTriggerEnter(ObjectReference akActionRef) If akActionRef == PlayerREF Int iIndex = DraugrArray.Length ; Will return 30 While iIndex iIndex -= 1 ; 29'th element is 30'th Draugr Actor kDraugr = DraugrArray[iIndex] kDraugr.EnableAI(bEnableBeasts) kDraugr.SetAlpha(bEnableBeasts As Float) EndWhile EndIf EndEvent</syntaxhighlight> Note that bEnableBeasts is a property so one can decide with each instance which way the script should work. One could use a FormList rather than an array or simply set one Draugr as the enable parent of the other 29 and enable/disable him, and thus all the children refs simultaneously. '''How to Make This Script Work''' * You will need to fill the array elements in the Creation Kit with the chosen creatures. * Then you will need to choose for each instance of the script whether the boolean property should be false or true, this setting process shows up a simple checkmark box in the editor.
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)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Landing page
Tutorials
Game Systems
Editor Reference
Scripting Reference
Recent changes
Help
Tools
What links here
Related changes
Special pages
Page information
Page values