Page 1 of 1

Declarinring in Global codes?

PostPosted: Sat Oct 02, 2010 3:35 am
by poopbrigade
Hey and Hello every one I'm making my game called BattleMage and I was thinking of transfering codes from one to another and maybe merging em but I bCus I'm tired of the repeating codes and I also tried to learn global thingys and learned a bit of it, now heres my question=>
How can I set a name of an animation to another 1 like
walk_L=WalkingLeftMonkeySlowly
so that I just asign their names and copy past codes.....

Thank in advance XD..... :mrgreen:

Re: Declarinring in Global codes?

PostPosted: Sun Oct 03, 2010 4:49 pm
by CybrKidX
That's a bit confusing... but if I understand you correctly, you want to apply the same change-animation code to multiple actors. To do this, you'll need the different actors to have the same animation names, such as Walk_left, Walk_right, etc.

Put this in your global code:
Code: Select all
void TurnLeft()
{
    *you may put any code here that you do not wish to repeat*
    ChangeAnimation("Event Actor", "Walk_left", FORWARDS);
}


Then, to use this code later on any actor you wish, you simply copy this into the script editor:
Code: Select all
TurnLeft();


Thats a subprocedure, by the way, and you can name it watever you want... I just chose TurnLeft for the example.

Re: Declarinring in Global codes?

PostPosted: Sun Oct 03, 2010 4:58 pm
by DST
As far as i know, you cannot actively change an animation name once it has been added to the animation list.

What you can do, however, is use define.

#define Walk_L WalkingLeftMonkeySlowly

If you aren't familiar: Put it in a global script window, and add as many as you want. Any time you type the first thing, it replaces it with the second.

Re: Declarinring in Global codes?

PostPosted: Mon Oct 04, 2010 2:28 am
by poopbrigade
thnx sry for the long reply my internet broke.
XD.. trying it now..

Re: Declarinring in Global codes?

PostPosted: Fri Nov 19, 2010 8:22 pm
by Fuzzy
Excessive use of the #define can make bug hunting painful and makes it harder to share code.

That being said its never stopped me. You can do some pretty nifty things with #define.