EMS Forums
Please login or signup to post on the forums.

Join the forum, it's quick and easy

EMS Forums
Please login or signup to post on the forums.
EMS Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Variable issue

2 posters

Go down

Variable issue Empty Variable issue

Post by Joegernaut Wed Apr 27, 2011 11:34 pm

Greetings mortals and mortalmen...

Well in my RTS game, I have a gas vent.
When the player touches that gas vent it begins building
After an alarm runs out, it turns into a building

When the gas vent is created, the variable stage = 1
When the player touches the gas vent, it goes into stage = 2 and sets an alarm
When this alarm runs out, the stage = 3 and the sprite turns into a built building.

Problem: The alarm doesn't seem to run out and when I test it on debug mode, it says the variable didn't change.

Request code if you want it

Joe
Joegernaut
Joegernaut
Corporal
Corporal

Posts : 78
Join date : 2011-04-18
Age : 27
Location : New Zealand

Back to top Go down

Variable issue Empty Re: Variable issue

Post by Water Chicken Wed Apr 27, 2011 11:36 pm

Yeah, I'll need some code. For all events involved.
Water Chicken
Water Chicken
Lieutenant
Lieutenant

Posts : 254
Join date : 2011-03-22
Age : 24
Location : Chandler, Indiana

Back to top Go down

Variable issue Empty Re: Variable issue

Post by Joegernaut Wed Apr 27, 2011 11:39 pm

Obj_Gas

Create event:

Code:
stage = 1
image_speed = 0.2

Alarm 0:

Code:
global.fuel = global.fuel + 100;
instance_create (self.x + 32,self.y + 48,Obj_Workerbot);
working = 0;

Alarm 1

Code:
instance_create (x+32,y+48,Obj_Workerbot)
stage = 3

Step

Code:
if stage = 2
{
    alarm[1] = 50
    sprite_index = Spr_Resource_Building_Being_Built;
    image_index=0;
    image_speed=1;
}
if stage = 3
{
    sprite_index = Spr_Resource_Building
    image_index=0;
    image_speed=1;
}

Collision with Obj_Workerbot

Code:
if stage = 1
{
    stage = 2
}
if stage = 3
{
    if (place_empty(self.x+32,self.y+48))
    {
        if working = 0
        {
            alarm[0] = 100
            working = 1
            with (other) instance_destroy();
            instance_create (self.x + 16,self.y,Obj_Making)
        }
    }
}
Joegernaut
Joegernaut
Corporal
Corporal

Posts : 78
Join date : 2011-04-18
Age : 27
Location : New Zealand

Back to top Go down

Variable issue Empty Re: Variable issue

Post by Water Chicken Wed Apr 27, 2011 11:43 pm

When checking if stage = 2, add and alarm[1] < 1.
You're constantly setting alarm[1] to 50.
Water Chicken
Water Chicken
Lieutenant
Lieutenant

Posts : 254
Join date : 2011-03-22
Age : 24
Location : Chandler, Indiana

Back to top Go down

Variable issue Empty Re: Variable issue

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum