Swapping the value of two numeric Attributes without a temp Attribute (try yourself before looking)
Hi again, another little snippet, especially helpful in GameSalad.
lets assume:
Usually when needing to swap the values of the two Attributes you would use a temporary Attribute:
To avoid cluttering Actors with temp Attributes you could do the following:
Voilà
This applies to numeric Attributes only though
lets assume:
A=3
B=4
Usually when needing to swap the values of the two Attributes you would use a temporary Attribute:
temp=A
A=B
B=temp
To avoid cluttering Actors with temp Attributes you could do the following:
A=A+B (=7)
B=A-B (7-4=3)
A=A-B (7-3=4)
Voilà
This applies to numeric Attributes only though
Comments
@Hopscotch
Neat! :-)
Clever (and useful) !