DrakeTheDragon Posted January 10, 2015 Share Posted January 10, 2015 If you want "x" to be "10", you use "x = 10".If you want "x" to be "10 more than it is", you use "x += 10". If "x" doesn't have a value yet, it doesn't matter which one you use. The result will be the same.But as soon as "x" was already set to anything else than "0", the results will be very different. Link to comment Share on other sites More sharing options...
ArronDominion Posted January 12, 2015 Share Posted January 12, 2015 "=" is used for giving variables values where modifiers such as "+=" are used to do quick value changes to an existing variable. So in this case, you created a variable "x". "x" does not know its value. You have to give it the value. "x = 10" gives "x" the value of 10. Now "+=": Let's say you gave "x" the value of 10. "x += 10" will translate to "x = x + 10" which translates to "x = 10 + 10" which gives "x" the value of 20. Calling "x += 10" again will translate to "x = x + 10" which translates to "x = 20 + 10" giving "x" the value of 30. Before this post, I always assumed a C-like approach to variables requiring a value before use, but it is good to know that Papyrus defaults values to 0. It is good practice to use "=" when you first create a variable instead of a modifier such as "+=". Using "=" will eliminate potential value-logic errors. Using "=" also allows for more complex operations in one line.Ex:"x = 10""x += Health""x -= Damage""x *= Weakness"can translate to"x = 10 + Health - Damage * Weakness" (In this statement use your order of operations, since Papyrus uses order of operations when assigning values. Damage*Weakness will be computed first with 10 + Health - ResultOfDamageWeaknessMultiplication being computed last) Link to comment Share on other sites More sharing options...
HailHell Posted January 13, 2015 Author Share Posted January 13, 2015 (edited) Thanks i got it now, basically if i write:x = 10x += 10x == 20 but if i write: x = 10x = 10x == 10x will just get assigend 10 but not added Edited January 13, 2015 by HailHell Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted January 13, 2015 Share Posted January 13, 2015 :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts