Difference between revisions of "Talk:Operator Reference"

1,174 bytes added ,  17:40, 25 August 2016
no edit summary
imported>Gurgate
(Created page with "this does not sound to be worded correctly to me. am i thinking about that too hard? :"The OR operator (||) will be true if one of the expressions to its left and right are t...")
 
imported>Goggle
 
Line 18: Line 18:
that last bit suggests we would never see 'x was evaluated'.
that last bit suggests we would never see 'x was evaluated'.
--[[User:Darkconsole|Darkconsole]] ([[User talk:Darkconsole|talk]]) 2016-08-25T16:26:29 (EDT)
--[[User:Darkconsole|Darkconsole]] ([[User talk:Darkconsole|talk]]) 2016-08-25T16:26:29 (EDT)
: You maybe misunderstanding it. The OR operator will short-circuit if the left expression is true. As in, it doesn't check the right expression if that's the case. If the left is false, it checks if the right is true. For a long chain of OR operators, it checks all of the right expressions when the first left expression is false, and short-circuits on the first right expression found to be true.
: Some easy example.. say your character has 10mm Ammo. You want to do things if it has 3 'or' 5 bullets.
<source lang="papyrus">
Function Foo()
Actor Player = Game.GetPlayer()
If Player.GetItemCount(10mmAmmo) == 3 || Player.GetItemCount(10mmAmmo) == 5
; if the player has 3 bullets OR 5 bullets, this code is processed.
EndFunction
</source>
From my understanding, the OR operator is a simple, yet potentially long-winded method of taking into account for things that may arise incase the desired expression is not met for some reason. It's like another way around an army of elseif statements, but you don't want TOO many OR expressions either. I hope I cleared that up.
--[[User:Twilight Sky|Twilight Sky]] ([[User talk:Twilight Sky|talk]]) 2016-08-25T18:40:57 (EDT)
Anonymous user