Jump to content

Need some clarification


HailHell

Recommended Posts

Its probably a stupid question but whatever.

Is assign the same as add in papyrus?

Because for example if i write

 

count += 1

count == 1 will now equal 1

but if

count == 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 count

so if count == 100

after count %= 5

count will == 105 yes?

Link to comment
Share on other sites

Its probably a stupid question but whatever.

Is assign the same as add in papyrus?

Because for example if i write

 

count += 1

count == 1 will now equal 1

but if

count == 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 count

so if count == 100

after count %= 5

count 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 = 10

x += 5

 

Will result in x equaling 15. If that makes any sense.

 

This explains all the operators thoroughly.

Link to comment
Share on other sites

I'm no guru with papyrus and I actually dislike it more then like it.

But

count += ; Would not compile as you need a value on the other side. eg: += Value

Int count = 100

count %= 5 ;count will return 0

Edited by smashly
Link to comment
Share on other sites

I just spent like the last 3 hours on wiki, ans they don't explain s#*&#33; thoroughly, maybe its just me because i don't have any experience in coding. but anyway

 

So what is the difference between writing

 

x = 10

and

x += 10

 

because in both cases x will end up as 10

and wtf does %= do and how can i use it?

Link to comment
Share on other sites

"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.

Link to comment
Share on other sites

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... yay

I 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.

Link to comment
Share on other sites

"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 writing

x = 10 <--- assign 10 to x

and

x += 10 <--- add 10 to x

 

but what does assign actually do and mean?

Link to comment
Share on other sites

x could be any value, maybe 0, maybe 100000, maybe 2 ....

 

when you declare

x = 10

It means x is 10 and not anything else.

 

when you

x += 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 value

Now 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.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...