Variable+Animation changing

Game Editor comments and discussion.

Variable+Animation changing

Postby Troodon » Fri Oct 06, 2006 12:21 pm

Hi everybody! Hi all my game editor forum friends!
It has been long time since I was active in this forum but I'm still in top writers list.
(Position 12th used to be 9th)

What's the best way to make this:
if variable kunto = 3 change animation to config2
if variable kunto = 2 change animation to config3
if variable kunto = 1 change animation to config4
if variable kunto = <0 destroya actor

Thanks!
(as you can see I've forgot little game editor)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby DilloDude » Sat Oct 07, 2006 6:33 am

Code: Select all
switch (kunto)
{
    case 0:
    DestroyActor("Event Actor");
    break;

    case 1:
    ChangeAnimation("Event Actor", "config4", FORWARD);
    break;

    case 2:
    ChangeAnimation("Event Actor", "config3", FORWARD);
    break;

    case 3:
    ChangeAnimation("Event Actor", "config2", FORWARD);
    break;
}
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Troodon » Sat Oct 07, 2006 11:22 am

Thanks! And that's working in the 1.3.3 (2005) version too?
EDIT: It's working! Sorry for distracting you but what if I want to destroy the actor when kunto is <1. Because in my game the kunto can change so fast that the actor doesn't get destroyed if it goes below zero. :wink:
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby DilloDude » Sat Oct 07, 2006 9:52 pm

just have your case 1, case 2, case 3, and then put default: DestroyActor... instead of in case 0. This will also make it destroy if it is greater than 3, though, unless you test it with an if.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Troodon » Sun Oct 08, 2006 7:24 am

DilloDude wrote:just have your case 1, case 2, case 3, and then put default: DestroyActor... instead of in case 0. This will also make it destroy if it is greater than 3, though, unless you test it with an if.

I know this is sounding very stupid but :oops: :oops: how do I made it default. If I make the destroy actor before switching, the actor will be always destroyed. So do I make like this?

Code: Select all
switch (kunto)
{
    default:
    DestroyActor("Event Actor");
    break;

    case 1:
    ChangeAnimation("Event Actor", "config4", FORWARD);
    break;

    case 2:
    ChangeAnimation("Event Actor", "config3", FORWARD);
    break;

    case 3:
    ChangeAnimation("Event Actor", "config2", FORWARD);
    break;
}
:oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops:
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby DilloDude » Sun Oct 08, 2006 10:16 am

Yes, only you will need to put the default after the other cases:
Code: Select all
switch...
{
case 0...
case 1...
case 2...
default...
}

this will do the script in the appropriate case if it is 0, 1, or 2, and if not, it will do the script in the default.
Also useful with switch statements, if you don't enter break at the end, it will keep going down the list of code and executing functions anyway. There are cases where you do want this to happen, but often you don't.
It may be best to think of it as one block of code, you check a variable and enter in at the appropriate entry point, and keep going till you come to a break.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest