• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Variable Value Detecting Help

G

Gavin Murdock

Guest
I am creating a game, where you click on an object to earn money. I have the counter working so that it adds every time the object is clicked. What I want to do next, is have an image pop up when a certain value is reached. Example, when the counter reaches 100 or something like that. So I guess I need a script to detect when that counter variable reaches a certain value. Any help?

PLEASE HELP
 
G

Gavin Murdock

Guest
Sorry Didn't work, maybe I put it in wrong but here's might I went wrong


if (counter >= goal) {
//do something
}

Is the counter the Variable and the goal the value?
 
G

Gavin Murdock

Guest
if (Money >= 100) {
//do something}
action_create_object( o_TutorialOverlay, 0, 0 ); }

This is the script I made its suppose to make an overlay show up when 100 dollars has been reached. If any of this is incorrect please let be know. Attached is the error that pops up.
 

Attachments

C

Crazy Star

Guest
You need to define the variable Money before you can use it.
(in the create event)
Code:
Money = 0;
You also need to respond to mouse clicks:
(in the step event)
Code:
if(mouse_check_button_pressed(mb_left))
{
  Money += 1;
 
  if (Money == 100)
  {
    //show overlay
    action_create_object(o_TutorialOverlay, 0, 0);
  }
}
 
G

Gavin Murdock

Guest
You need to define the variable Money before you can use it.
(in the create event)
Code:
Money = 0;
You also need to respond to mouse clicks:
(in the step event)
Code:
if(mouse_check_button_pressed(mb_left))
{
  Money += 1;
 
  if (Money == 100)
  {
    //show overlay
    action_create_object(o_TutorialOverlay, 0, 0);
  }
}
sorry, CrazyStar I don't know what you mean by Step event. I know there is a step event but I don't know how to use it. I am a beginner with programming in general
 
G

Gavin Murdock

Guest
HEY IT WORK but now it won't count the number of clicks on the counter here's a video
 
Top