HailHell Posted January 10, 2015 Posted January 10, 2015 Its probably a stupid question but whatever.Is assign the same as add in papyrus?Because for example if i write count += 1count == 1 will now equal 1but ifcount == 1 and i write:count +=count == 2 count will equal 2 so just to be clear, assign means add yes?is this correct?:count %= 5 <--- will get 5% of count and add it to countso if count == 100after count %= 5count will == 105 yes?
Mattiewagg Posted January 10, 2015 Posted January 10, 2015 On 1/10/2015 at 2:18 AM, HailHell said: Its probably a stupid question but whatever.Is assign the same as add in papyrus?Because for example if i write count += 1count == 1 will now equal 1but ifcount == 1 and i write:count +=count == 2 count will equal 2 so just to be clear, assign means add yes?is this correct?:count %= 5 <--- will get 5% of count and add it to countso if count == 100after count %= 5count will == 105 yes?== is used for comparison, so: If x == y = is used for assigning a value, which is NOT the same as adding: x = 10 += is used for adding a value to the current value of something, so: x = 10x += 5 Will result in x equaling 15. If that makes any sense. This explains all the operators thoroughly.
smashly Posted January 10, 2015 Posted January 10, 2015 (edited) I'm no guru with papyrus and I actually dislike it more then like it.Butcount += ; Would not compile as you need a value on the other side. eg: += ValueInt count = 100count %= 5 ;count will return 0 Edited January 10, 2015 by smashly
HailHell Posted January 10, 2015 Author Posted January 10, 2015 I just spent like the last 3 hours on wiki, ans they don't explain s#*! thoroughly, maybe its just me because i don't have any experience in coding. but anyway So what is the difference between writing x = 10andx += 10 because in both cases x will end up as 10and wtf does %= do and how can i use it?
DrakeTheDragon Posted January 10, 2015 Posted January 10, 2015 "x += 10" will always ever end up as "10" as well, if "x" was "0" previously. Actually typing "x += 10" is the exact same as typing "x = x + 10" instead. As for this "%=" modifier, that's the "modulus" modifier rather than anything to do with "percentage". Modulus is divide A by B and return the rest.I've personally never seen the modulus modifier used together with an assignment like in "%=", and I'm programming in several different languages from Basic to C++ since the age of 4, but logic dictates it will do nothing else but"x = x % 5"that is, divide x by 5 and put the rest into x. I'm mostly using "%" to determine whether A is a multiple of B in comparisons like "if x % 10 == 0", as it will only return "0", if "x" is indeed a multiple of "10". But that's just an example.
smashly Posted January 10, 2015 Posted January 10, 2015 Ahh so that's the mod function I was looking for and couldn't find, thank you.Last scripting language I used had a native Mod(Value, Value) listed in it's math functions, so in papyrus I looked at the math functions and wondered where it was, all the other little math functions I used in the other scripting language were there, so I improvised. Now I can go back and rewrite my code the way I wanted... yayI use Mod mainly when creating with GUI controls in loop and wanting to align x or y position every so many controls, in this instance MCM with 250 lots of 5 controls.It's the little things that make me happy.
HailHell Posted January 10, 2015 Author Posted January 10, 2015 On 1/10/2015 at 8:02 AM, DrakeTheDragon said: "x += 10" will always ever end up as "10" as well, if "x" was "0" previously. Actually typing "x += 10" is the exact same as typing "x = x + 10" instead.thank you for clearing almost everything up, but i am still confused by the difference of writingx = 10 <--- assign 10 to xandx += 10 <--- add 10 to x but what does assign actually do and mean?
smashly Posted January 10, 2015 Posted January 10, 2015 x could be any value, maybe 0, maybe 100000, maybe 2 .... when you declarex = 10It means x is 10 and not anything else. when youx += 10 You are adding 10 to the value of x Maybe look at it this way.x = 100 I'm declaring x is 100 and not any other valueNow I want to add 10 to the x value x += 10 x would now be 110 x = value is declaring that's what x equals x += value is adding the value to x and x could be any value to start with.
HailHell Posted January 10, 2015 Author Posted January 10, 2015 ok, are there any instances where it would be important to use x = 10and notx += 10 and vice versa?
HailHell Posted January 10, 2015 Author Posted January 10, 2015 i am probably overanalising this but i am new to progarmming so i have no idea what is important and what is not
Recommended Posts