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

Question - Code problem of cutscene code

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Hell wither, Aug 24, 2019.

  1. Hell wither

    Hell wither Member

    Joined:
    Aug 18, 2019
    Posts:
    7
    I watched a cutscene tutorial and do exactly what she taught,but I got the following error when running

    FATAL ERROR in
    action number 1
    of Other Event: User Defined 0
    for object oCutscene:

    trying to index a variable which is not an array
    at gml_Object_oCutscene_Other_10 (line 1) - current_scene=scene_info[scene];

    stack frame is
    gml_Object_oCutscene_Other_10 (line 1)
    called from - gml_Object_oCutscene_Create_0 (line 9) - event_perform(ev_other,ev_user0);


    as you see there is a cutscene object, and the its codes are as following

    upload_2019-8-25_1-56-18.png upload_2019-8-25_1-56-32.png upload_2019-8-25_1-56-44.png

    the error said the array is wrong but actually it's saved in a script_execute_alt.I downloaded it from internet so it can't be wrong. anyone can help me with the problem´╝č
     
  2. Hell wither

    Hell wither Member

    Joined:
    Aug 18, 2019
    Posts:
    7
    anyone can help me please:(
     
  3. curato

    curato Member

    Joined:
    Jun 30, 2016
    Posts:
    438
    scene_info isn't an array you can't use square brackets to index it
     
  4. Hell wither

    Hell wither Member

    Joined:
    Aug 18, 2019
    Posts:
    7
    Ok, what should I do to fix this, by creating a new array? actually the tutorial does the same thing as I do, but it's running successfully, and array worked as well
     
  5. curato

    curato Member

    Joined:
    Jun 30, 2016
    Posts:
    438
    you would need to post all the code to be able to tell more (not screen shots please). I can tell that is the issue from the error you posted and the create event screen you declare it as a regular variable equal to -1 on line 1 then of line 1 of the userevent0 you reference it like an array. Unless you didn't something radical in between that not going to work at all. My guess is your code varies from the tutorial and there in lies your problem.
     
  6. Hell wither

    Hell wither Member

    Joined:
    Aug 18, 2019
    Posts:
    7
    I watched the tutorial over and over but can't find any differences.but it does change some codes into a simpler version. for example, in the step screen, it included an array like this:
    var current_scene=scene_info;

    var len =array_length_1d(current_scene)-1;

    switch(len){
    case 0: script_execute(current_scene[0]); break;
    case 1: script_execute(current_scene[0],current_scene[1]); break;
    case 2: script_execute(current_scene[0],current_scene[1],current_scene[2]);break;
    }
    therefore the real array was in the create event and the code was like this
    upload_2019-8-26_0-19-26.png
    I can put in scripts to run the array
    because this version looks messy and need to many arguments so she used a script(script_execute_alt)instead:
    Code:
    ///@description script_execute_alt
    ///@arg ind
    ///@arg [arg1,arg2,...]
     
    var s = argument0;
    var a = argument1;
    var len = array_length_1d(argument1);
     
    switch(len){
        case 0 : script_execute(s); break;
        case 1 : script_execute(s, a[0]); break;
        case 2:  script_execute(s, a[0], a[1]); break;
        case 3:  script_execute(s, a[0], a[1], a[2]); break;
        case 4:  script_execute(s, a[0], a[1], a[2], a[3]); break;
        case 5:  script_execute(s, a[0], a[1], a[2], a[3], a[4]); break;
        case 6:  script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5]); break;
        case 7:  script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6]); break;
        case 8:  script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); break;
        case 9:  script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); break;
        case 10: script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]); break;
        case 11: script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10]); break;
        case 12: script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11]); break;
        case 13: script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12]); break;
        case 14: script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13]); break;
        case 15: script_execute(s, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14]); break;
        
    }
    I don't think there is anything wrong with it. then she created a user event0 and moved scene_info into it. by the way the current_scene was a temporary variable at first. in the simpler version it changed into global. I think that' s all I can find now, but I will watch the tutorial again in order to find something different
     
  7. BaBiA Game Studio

    BaBiA Game Studio Member

    Joined:
    Jun 20, 2016
    Posts:
    922
    Look at your user event and see the difference here. This line is referencing the scene_info array, yet your event is just getting the first value from the scene_info array.
    Perhaps you should also tell us what tutorial you are using (a link might be nice) so anyone can actually check to see if you have made a mistake. As you have said "she", I'm guessing you are using a friendly cosmonaut tutorial.
     
  8. Hell wither

    Hell wither Member

    Joined:
    Aug 18, 2019
    Posts:
    7
    No matter I add the var or delete it, the error that appears is still the same.
    and you guess is right, I watched friendly cosmonaut's tutorial. Here is the link


     

Share This Page