• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code problem of cutscene code

Hell wither

Member
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.pngupload_2019-8-25_1-56-32.pngupload_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?
 

Hell wither

Member
scene_info isn't an array you can't use square brackets to index it
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
 

curato

Member
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.
 

Hell wither

Member
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.
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
 
var current_scene=scene_info;
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.
 

Hell wither

Member
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.
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
 
Top