Difference between revisions of "Papyrus Introduction"

1 byte removed ,  18:54, 20 January 2012
m
→‎Example Script (extending ObjectReference): Grammar fix - it's (contraction) -> its (possessive pronoun)
imported>Cipscis
m (→‎Example Script (extending ObjectReference): Grammar fix - added a missing apostrophe)
imported>Cipscis
m (→‎Example Script (extending ObjectReference): Grammar fix - it's (contraction) -> its (possessive pronoun))
Line 67: Line 67:
Game.GetPlayer() is a function [[GetPlayer - Game|GetPlayer()]] on the [[Game Script]] that returns the [[Actor Script|Actor]] that represents the player. The == is a test (a "[[Operator_Reference#Comparison_Operators|Comparison Operator]]") which means “is this thing exactly this other thing?” So we are asking is the [[reference]] that the game sent to our script when an actor entered our trigger box, is that the same as the actor [[reference]] returned by Game.GetPlayer()? In other worlds “did the player enter the trigger?” If so, then call the SetStage() function on the quest that is in the MyQuest property, and tell it the stage we want to set is whatever we have stored in the StageToSet property.
Game.GetPlayer() is a function [[GetPlayer - Game|GetPlayer()]] on the [[Game Script]] that returns the [[Actor Script|Actor]] that represents the player. The == is a test (a "[[Operator_Reference#Comparison_Operators|Comparison Operator]]") which means “is this thing exactly this other thing?” So we are asking is the [[reference]] that the game sent to our script when an actor entered our trigger box, is that the same as the actor [[reference]] returned by Game.GetPlayer()? In other worlds “did the player enter the trigger?” If so, then call the SetStage() function on the quest that is in the MyQuest property, and tell it the stage we want to set is whatever we have stored in the StageToSet property.


If you have been following along carefully, you may wonder at how we can compare an [[ObjectReference Script|ObjectReference]] "akActionRef" to an [[Actor Script|Actor]] (the return value of Game.GetPlayer()). The reason we can do this is because the compiler knows that all Actors are also ObjectReferences because the [[Actor Script]] '''[[Extending_Scripts_(Papyrus)|extends]]''' the [[ObjectReference Script]]. So here you see that extension isn't used only for your own scripts, but the base scripts also extend each other as well! The wiki writeup for each [[:Category:Script Objects|Script Object]] contains at the top of it's page, which script it is extending from.
If you have been following along carefully, you may wonder at how we can compare an [[ObjectReference Script|ObjectReference]] "akActionRef" to an [[Actor Script|Actor]] (the return value of Game.GetPlayer()). The reason we can do this is because the compiler knows that all Actors are also ObjectReferences because the [[Actor Script]] '''[[Extending_Scripts_(Papyrus)|extends]]''' the [[ObjectReference Script]]. So here you see that extension isn't used only for your own scripts, but the base scripts also extend each other as well! The wiki writeup for each [[:Category:Script Objects|Script Object]] contains at the top of its page, which script it is extending from.




Anonymous user