1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

GMS 2 Script Not Working with YYC but Works with VM

Discussion in 'Programming' started by KyleRansford, Apr 19, 2019.

  1. KyleRansford

    KyleRansford Member

    Joined:
    Oct 29, 2018
    Posts:
    84
    Hello, when I finished a demo of a game in development my testing was done using the VM (Virtual Machine) export and everthing worked like it should. But, when I exported using the YYC (YoYo Compiler) the attached script doesn't work. It just hangs up.

    These are custom scripts by the way.

    Code:
    [script_cutscene_instance_create_with_alpha, 0, 0, "Instances", Title_Cutscene1],
    [script_cutscene_wait, 1],
    [script_cutscene_alpha_increase, Title_Cutscene1, 0.01],
    [script_cutscene_wait, 5], //Code gets stuck here
    [script_cutscene_alpha_decrease, Title_Cutscene1, 0.01],
    What the script should do is, when the game starts the player selects New Game and a Title Cutscene starts. But it gets stuck on the first cutscene image and won't go any further.

    I added the function to skip the cutscene to see if everything else is working ok and it appears it is. I know I'm not giving much of example in terms of code, but has this happened to anyone else? or does anyone know what it could be?

    Update: Further testing shows it's not counting the "counter" like it's supposed to.
    This is the script_cutscene_wait script with the counter.

    Code:
    timer_ += 1;
    
    if timer_ >= argument0 * room_speed {
        timer_ = 0;
        script_cutscene_end_action();
    }
     
    Last edited: Apr 19, 2019
  2. The Reverend

    The Reverend Member

    Joined:
    Sep 8, 2016
    Posts:
    570
    Use brackets in your if statement.
    Code:
    if (timer_ >= (argument0 * room_speed))
    
    Otherwise one compiler could compare the timer with argument0 times roomspeed and and another compiler could compare the timer just with argument0. The brackets make sure its the same everywhere.
     
    Last edited: Apr 19, 2019
  3. vdweller

    vdweller Member

    Joined:
    Jun 24, 2016
    Posts:
    144
    Do a debug print of timer_ , argument0 and room_speed and see exactly where there is s problem. Also just to be sure, room_speed is for legacy support although I doubt this is the problem.
     
  4. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,506
    It would be lovely if everyone stopped spreading this myth, cause people are blindly rewriting their game code absolutely for nothing.

    Give the following a go:
    Code:
    var a = 1;
    var b = 0;
    show_debug_message(a >= 0 * b);
    
    If it was grouped as you claim, you would get 0 on YYC, but you don't, because this is such an obvious thing that compiler can add parentheses where needed:
    Code:
    YYGML_show_debug_message((/* local */local_a >= (0 * /* local */local_b)));
     
    JesterOC, The Reverend and vdweller like this.
  5. vdweller

    vdweller Member

    Joined:
    Jun 24, 2016
    Posts:
    144
    +1000
     
  6. The Reverend

    The Reverend Member

    Joined:
    Sep 8, 2016
    Posts:
    570
    Thx @YellowAfterlife
    I had an issue with an if statement once on YYC and brackets fixed it. But instead of thoroughly testing when the issue occurred i simply deducted it's always an issue. Sloppy me ;)
     
  7. KyleRansford

    KyleRansford Member

    Joined:
    Oct 29, 2018
    Posts:
    84
    Thanks for your replies, The brackets didn't help though, and it seems like there's a problem with the "timer_" It doesn't seem to be incriminating like it should. I even tried it without the "room_speed" function and it still freezes.
    What is weird though, is that the "timer_" works for increasing the cutscene image alpha, but then the image just freezes and the alpha doesn't decrease.

    No self promo intended, but if you watch this YouTube trailer of my game, this is how the cutscene should go. And to show you what it does, it hangs up once "A Long Time Ago" appears.
    Video: (I removed the video so it doesn't seem like self promotion)
     
    Last edited: Apr 19, 2019
  8. KyleRansford

    KyleRansford Member

    Joined:
    Oct 29, 2018
    Posts:
    84
    Well, I think it's fixed now.
    I don't know why it worked in the VM export anyway, but, what I found was that the script for increasing the image alpha was set using code like
    Code:
    argument0.image_alpha += argument1;
    
    if argument0.image_alpha == 1 {
        script_cutscene_end_action();
    }
    So I believe the culprit was the alpha value would hardly ever hit exactly "1". So instead of using "==" I put ">=" in it's place.
    Now it's
    Code:
    argument0.image_alpha += argument1;
    
    if argument0.image_alpha >= 1 {
        script_cutscene_end_action();
    }
    and using the YYC it now continues the cutscene.
     
  9. vdweller

    vdweller Member

    Joined:
    Jun 24, 2016
    Posts:
    144
    Ah yes, you have to be (even more) careful when using == with YYC, I believe there was an article around about it but can't find it.
     

Share This Page