Difference between revisions of "States (Papyrus)"
Added example of priorities of how functions are picked
imported>Ereksen m |
imported>Mojo (Added example of priorities of how functions are picked) |
||
Line 80: | Line 80: | ||
In short, functions inside states override functions inside the 'empty state', and functions inside derived scripts override the ones in the scripts they extend. | In short, functions inside states override functions inside the 'empty state', and functions inside derived scripts override the ones in the scripts they extend. | ||
For example: | |||
<source lang="papyrus"> | |||
Scriptname ParentScript extends Quest | |||
Function MySuperCoolFunction() | |||
Debug.Notification("HELLO WORLD!") | |||
endFunction | |||
State StateThree | |||
Function MySuperCoolFunction() | |||
Debug.Notification("I saw a mudcrab the other day...") | |||
endFunction | |||
endState | |||
</source> | |||
<source lang="papyrus"> | |||
Scriptname ChildScript extends ParentScript | |||
State StateOne | |||
Function MySuperCoolFunction() | |||
Debug.Notification("STOP RIGHT THERE CRIMINAL SCUM!") | |||
endFunction | |||
endState | |||
State StateTwo | |||
Function MySuperCoolFunction() | |||
;do nothing | |||
endFunction | |||
endState | |||
State StateThree | |||
;MySuperCoolFunction() not defined | |||
endState | |||
; | |||
State StateFour | |||
;MySuperCoolFunction() not defined | |||
endState | |||
</source> | |||
If we call MySuperCoolFunction() on ChildScript, here are the results of what notification is printed in the four defined states. | |||
*StateOne - "STOP RIGHT THERE CRIMINAL SCUM!" - Priority 1. | |||
*StateTwo - Nothing happens - Also Priority 1. | |||
*StateThree - "I saw a mudcrab the other day..." - Priority 2 | |||
*StateFour - "HELLO WORLD!" - Priority 4 - If we had a function defined in our empty state of ChildScript, then that function will run instead per Priority 3. | |||
=How to Set a Script's State= | =How to Set a Script's State= |