Page 1 of 1

Simple but useful: Active Actors

PostPosted: Mon Mar 07, 2011 12:56 am
by Hblade
Hey everyone! :D Here is a little thing I'm doing, called SBU (Simple but useful), and I'm going to be doing quite a lot of these. They're simple functions that allow for a quick help and shortn' things down a bit, so say you have a bunch of stuff you use often, this is what thats for! :D

Sorry if I'm not making any sense I'm super tired >.>


Anyways, this one is "Active Actors", it enables you too activate or de-activate a player via variable. So say if your walking and you want a cutscene to go, all you'd do is this:
Code: Select all
active(0, "player");

and wadda bing the "player" actor becomes unable to do commands xD This is useful for those who are using Draw Actor to handle the players movement.

How to use:
Make an actor variable called "enabled", thats it xD Then in Draw Actor, do this:
Code: Select all
if (enabled) {
    your code here to be ran when enabled is on
}



Now for the actual script:
Code: Select all
void active(int value, char *actor) {
    Actor *act = getclone(actor);
    act->enabled=value;
                                   }


Simple right? but yet so useful xD

Re: Simple but useful: Active Actors

PostPosted: Mon Mar 07, 2011 2:55 pm
by lcl
Very simple. :D
For making it even more user freindly, use #define.
Like:
#define ENABLED 1
#define DISABLED 0

Then can use: active(DISABLED, "player");
:D

Nice anyway! :)

Re: Simple but useful: Active Actors

PostPosted: Mon Mar 07, 2011 3:25 pm
by Game A Gogo
are they not already declared defaultly in GE? Some GE functions uses them, so you too can use them without defining them, otherwise it will give you an error

Re: Simple but useful: Active Actors

PostPosted: Mon Mar 07, 2011 3:25 pm
by Hblade
Yeah :P

Re: Simple but useful: Active Actors

PostPosted: Mon Mar 07, 2011 4:49 pm
by lcl
Game A Gogo wrote:are they not already declared defaultly in GE? Some GE functions uses them, so you too can use them without defining them, otherwise it will give you an error

Yeah. Not sure about ENABLED and DISABLED, but ENABLE and DISABLE are. :D

Re: Simple but useful: Active Actors

PostPosted: Mon Mar 07, 2011 4:50 pm
by Hblade
Hehe :)