GM:S 1.4 issue calling script

Discussion in 'Programming' started by EZTALES, Jan 10, 2019.

  1. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    hey yall,
    i don't know if im doing this right but when i want to call my script it gives me a malformed if statement. heres the code below. Whats suppose to happen is when i press enter i want the script to open and replace the other one.
    Code:
    SCR_BMENU
    ///placeholder
    switch (mpos)
    {
    
    case 0:
    {// ATTACK
    script_execute(scr_attack);
    break;
    }
    
    case 1:
    {// SPELLS
    
    break;
    }
    
    case 2:
    {// INFO
    
    break;
    }}
    THX
     
  2. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    1,870
    There's nothing inherently wrong with the code you posted. There's also no if statement. Are you sure this is the code with the issue?

    Also, your question is a little confusing. You say 'malformed if statement' but don't post an if statement. You say 'when i press enter' but none of that is reflected in the code you posted. Is it in the step event, an enter specific gm event, something else? You say 'i want the script to open and replace the other one'. Which script is supposed to open? Why would it open. You haven't posted that code. Which script is the 'other one' and why would it be replaced? You haven't posted that code.

    In other words, you probably need to reask the question to more clearly state what you want answered.
     
  3. immortalx

    immortalx Member

    Joined:
    Sep 6, 2018
    Posts:
    296
    Check if you put a semicolon by accident after the if statement
    Code:
    if (condition); // This is wrong. Remove this semicolon
     
  4. RefresherTowel

    RefresherTowel Member

    Joined:
    Jul 13, 2016
    Posts:
    1,101
    You do not need the curly brackets for the cases in a switch statement:
    Code:
    switch (mpos) {
      case 0:
        // ATTACK
        script_execute(scr_attack);
      break;
      case 1:
        // SPELLS
      break;
      case 2:
        // INFO
      break;
    }
     
  5. BaBiA Game Studio

    BaBiA Game Studio Member

    Joined:
    Jun 20, 2016
    Posts:
    783
    Try showing us the actual error you are getting, as that will normally tell you exactly where the error is. As has been already mentioned, there is no if anywhere in that code you showed, so the problem must be inside your script where you have incorrectly set up an if statement.
     
  6. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    whoops! wrong code sent out, heres the problem one:
    Code:
    ///placeholder
    switch (mpos)
    {
    
    case 0:
    {// ATTACK
    if keyboard_check_pressed(vk_enter);
    {script_execute(scr_attack)};
    break;
    }
    
    case 1:
    {// SPELLS
    
    break;
    }
    
    case 2:
    {// INFO
    
    break;
    }}
    what i want it to do is open the menu.
     
  7. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    i just don't want to make multiple rooms for each fight. its a turn base rpg
     
  8. BaBiA Game Studio

    BaBiA Game Studio Member

    Joined:
    Jun 20, 2016
    Posts:
    783
    You have a ; at the end of the line. That is not how you do an if statement. Get rid of the ;
    If you ever get a "malformed..." type of error it is usually because you have done this.
     
  9. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    Very useful, thanks!
     
  10. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    166
    heres a look at what its suppose to do in my menu. for now, i ended up making a few rooms for different menus. that will be temporary though, i just wanted to see what it would look like.
     

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