• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Trying to index variable that is not an array

Heathenlamb

Member
Hey guys ... need your infinite wisdom once again. I am getting this error when I install the project on another pc.

"Trying to index variable that is not an array ... alarm 0 line 4"

So it only throws this error when I install it on another pc other than the one I am developing on. If I run it on my dev PC it runs fine without an issue. Here is the code -

CREATE -
Code:
next = 0;
vidpath = "C:\content/";
count = 0;
var i = 0;
fileName = file_find_first_ns(vidpath+"*.mp4");

while(fileName != "")
{
    fArray[i] = fileName;
    fileName = file_find_next_ns();
    i += 1;
}

file_find_close_ns();
vidcount = array_length_1d(fArray);
result_init = video_init( window_device() );
alarm_set(0, 1);

ALARM 0 -
Code:
application_surface_enable( false );

room_speed = 60;

nextvideo = fArray[next]

vidselect = vidpath + nextvideo

result_load = video_load(vidselect);

result_draw = 0;
result_time = 0;
result_duration = 0;
video_surface = 0;

video_set_loop(false);

video_play()

count = count + 1;

alarm_set(2, 10);
So it reads the mp4 content from a folder and puts the file names in an array, then uses that array to create a dynamic loopable playlist. As I said, it runs perfectly on the pc I use to develop the project. But when I install it on another pc I keep getting that error. I understand the nature of what it is saying but after staring at the code for days I simply can not work out what the hell is wrong. It is compiled with YYC.

Any help or advice would be greatly appreciated.
 
Last edited:
L

Lonewolff

Guest
Are there any files in the folder in the other PC?

Seems to me that if there are no files then fArray will never get defined.
 

FrostyCat

Redemption Seeker
If the path does not exist on your other system, then fArray will never be set.

Also, DO NOT post code in plain text or any manual styling, use [code] and [/code] tags. It is particularly important for your particular issue, because like many pieces involving the iteration of arrays, the character sequence [i] appears in the code. This interferes with the BBCode parser and corrupts the code you post. Right now, I cannot tell if you did this (correct):
Code:
fArray[i] = fileName;
Or this (clearly incorrect):
Code:
fArray = fileName;
Putting code between [code] and [/code] tags prevents the BBCode parser from acting on your code and preserves all tab spacing needed for reading indentations.
 

Heathenlamb

Member
Yes there are files on the other pc ... and yes the path does exist.

I apologise about the code posting thing. I have been posting code on here for years and that is the first time I have heard about this ... OK ... all fixed !
 
I have been posting code on here for years and that is the first time I have heard about this
It's been in the guidelines for years. You may need to repost your code again in code tags as it looks like it is still doing the italics as it was in your original post so it looks like fArray is not actually set up as an array:
Code:
fArray = fileName;
 

Heathenlamb

Member
It's been in the guidelines for years. You may need to repost your code again in code tags as it looks like it is still doing the italics as it was in your original post so it looks like fArray is not actually set up as an array:
Code:
fArray = fileName;
Oh I am not disputing that it has been a rule for yrs. Just simply stating that I was never aware of it until now ... as far as I can tell the code is presenting properly now.

So this is how it actually presents in the code now I have fixed it -

Code:
fArray[i] = fileName;
Hence my frustration at why it is not working.
 
As has been mentioned by others, is there actually that folder "C:\content" on the other pc, and are there any .mp4 files in that folder on that pc. If not, then fArray will not get set with anything. Also, what is the file_find_first_ns function? I can't see that in the docs, so don't know what it is doing. Is it something to allow you to reference a folder outside the sandbox environment?
 

Heathenlamb

Member
Yes the folder is there and has files ... file_find_first_ns is a command from a non-sandboxed extension i have running in the project.
 
Top