Swapping the value of two numeric Attributes without a temp Attribute (try yourself before looking)
Hopscotch
Member, PRO Posts: 2,782
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
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@Hopscotch
Neat! :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Clever (and useful) ! >-