GM:S 1.4 Debug error pls

Discussion in 'Programming' started by prithvidiamond, Jun 27, 2016.

  1. prithvidiamond

    prithvidiamond Member

    Joined:
    Jun 21, 2016
    Posts:
    39
    Pls debug what mistake I have made i the code below and what best can be done:

    //inside step event
    var inst;

    if (mouse_check_button_pressed(mb_left) and inst = collision_point(mouse_x, mouse_y, fruit = fruitguess, true, true));
    {
    points += 1

    script_execute = scr_draw_obj1;
    script_execute = scr_draw_obj2;

    }

    all help is appreciated,

    prithvidiamond
     
  2. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    The way you use = is invalid.
    If you use = inside an if statement, then it will be treated as a comparison, not as an assignment.
    The same goes for using = inside an argument expression of a function.
    And assigning a script to script_execute is invalid as well, you should rather use: scr_draw_obj1(...);
     
  3. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,287
    Let's be absolutely honest here, do you even understand what you just wrote?
    • Why are you trying to initialize inst in the middle of an if condition?
    • What kind of object/instance ID is fruit = fruitguess?
    • Why are you attempting to run scripts like this when the Manual clearly instructs otherwise?
    Quit the blind trial-and-error and read the Manual entries on basic GML form, then follow its instructions instead of making up nonsense in panic. If you are too panicked to think straight, put the keyboard down until you can. If it doesn't make sense to another human, it can only make less sense to a parser.
     
  4. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,399
    In the future it's helpful if you explain why you want code debugged. Did your game crash? Did it freeze? Did you get an error? Did something happen you didn't expect? When you have errors that's the first thing you need to share.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice