Difference between revisions of "Variables and Properties"
Jump to navigation
Jump to search
m
→From Within a Magic Effect Script: Formatting tweaks, spelling error fix, and additional info added to examples.
imported>Cipscis m (→Declaring Variables: Fixing grammar mistake - it's -> its) |
imported>Delfofthebla m (→From Within a Magic Effect Script: Formatting tweaks, spelling error fix, and additional info added to examples.) |
||
Line 145: | Line 145: | ||
All scripts can access other scripts, however they can ''only'' access the script's properties. | All scripts can access other scripts, however they can ''only'' access the script's properties. | ||
Let's look at an example where a spell accesses a quest's properties: | |||
Let's look at an example where a scripted spell accesses a quest's properties: | |||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Scriptname myQuestNameScript extends Quest | Scriptname myQuestNameScript extends Quest | ||
Int Property | Int Property PublicDamage Auto ; This value is defined as a property and can be accessed from outside this script | ||
Int | Int PriviteDamage = 30 ; This value is private to the script and cannot be accessed from outside this script | ||
Function | Function DamageTargBasedOnPublic(Actor akTarget) | ||
;This code will damage the akTarget for PublicInt damage | |||
akTarget.DamageAV("Health", PublicInt) | |||
EndFunction | |||
Function DamageTargBasedOnPrivate(Actor akTarget) | |||
;This code will damage the akTarget for PublicInt damage | ;This code will damage the akTarget for PublicInt damage | ||
akTarget.DamageAV("Health", PublicInt) | akTarget.DamageAV("Health", PublicInt) | ||
Line 159: | Line 165: | ||
</source> | </source> | ||
Now that we have defined our quest script and created an | |||
Now that we have defined our quest script and created an accessible property, we can control it from the outside. | |||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Scriptname mySpellEffectScript extends activemagiceffect | Scriptname mySpellEffectScript extends activemagiceffect | ||
Line 166: | Line 173: | ||
Event OnEffectStart(Actor akTarget, Actor akCaster) | Event OnEffectStart(Actor akTarget, Actor akCaster) | ||
myQuestRef.PublicInt = 20 | myQuestRef.PublicInt = 20 ; This will change the damage for the DamageTargBasedonPublic Function | ||
myQuestRef. | myQuestRef.DamageTargBasedOnPublic(akTarget) ; You can manipulate this damage by changing PublicDamage Prior to calling it | ||
myQuestRef.DamageTargBasedOnPrivate(akTarget) ; This will always do 30 damage unless the quest changes the private variable | |||
EndEvent | EndEvent | ||
</source> | </source> | ||
=Getting Properties From Any Other Script= | =Getting Properties From Any Other Script= |