How do I make it to where if variable equals to a variable..

Get help using Construct 2

Post » Thu Jul 06, 2017 8:28 pm

Basically in Construct 2 how do I do

A1:
Code: Select all
if (how_many_pizzas_I_have == my_hp) //if variable how_many_pizzas_I_have is equal to my_hp
{
 x += 5; //go right by five pixels;
}



B1:
Code: Select all
if (instance_exists(100012)) //if in room an instance of an object with id 100012 does exist
{
  if (instance_exists(100711)) //if in room an instance of an object with id 100711 does exist
  {
    if ((100711).hp == (100012).my_money)) //if instance of an object that has id of 100711 has variable hp that is equal to variable my_money of instance of an object that has id of 100012
    {
        (100711).y -= 17; //instance of an object with id of 100711 goes down by 17 pixels
    }
  }
}





Also regarding Construct 2 if someone buys Construct 2 from Steam does Construct 2 bought from Steam come with absolutely (unrestrictedly) all exporting possibilities as Construct 2 bought elsewhere?
B
6
S
1
Posts: 9
Reputation: 368

Post » Thu Jul 06, 2017 8:43 pm

It's system > compare Global/Local variable or object > compare Instance Variable depending on which it is. System compare TotalPizza = PlayerHP > do action.
B
46
S
16
G
76
Posts: 2,150
Reputation: 45,313

Post » Thu Jul 06, 2017 8:46 pm

Code A1.

Add a global variable 'how_many_pizzas_I_have' (number) to the events sheet.
Add a global variable 'my_hp' (number) to the events sheet.

Add a new new event to the sheet.
Click the object that you want to move and choose a condition that picks that object.
Add Another conditions to the same event.
System > Compare two values ... First value = 'how_many_pizzas_I_have' .. = Equal to .. Second value = 'my_hp'

Add an action to that event > Click the object that you gonna move > choose Set X .... X = self.x + 5
Last edited by 99Instances2Go on Thu Jul 06, 2017 8:58 pm, edited 1 time in total.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jul 06, 2017 8:58 pm

Code B1

Add a Family. Add 'object' to the family.
Add an instance variable 'id' to the family.
Add an instance variable 'hp' to the family
Add an instance variable 'my_money' to the family
Get some code in place that gives numbers to 'id'.

Add an event.
Object > Is on Screen
Family > is on screen
Object > Compare instance variable > Id = 100012
Family > Compare instance variable > Id = 100711
System > Compare two values ... First value = object.hp = Equal to .. Second value = Family.my_money

Add an action to that event > Family > choose Set X .... X = self.x + 17
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests