• 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!

Fatal Error (Illegal Array Use)

B

Ben Hubble

Guest
I'm making an 2-player, 2d arena-style shooter, and i'm currently making enemies. I thought my code would wprk until this comes up:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_spawn:

DoConv :1: illegal array use
at gml_Script_scr_check_spawn
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_check_spawn (line 0)
gml_Object_obj_spawn_Step_0

It's so confusing because that script and object didn't even use any arrays. And the in the whole game the only arrays I've used is the alarms. When I call the script it's in it's own code, all that's in it is scr_check_spawn(spawn_rate) and the code for that script is:
Code:
if(obj_network.is_server == true) {
var spwn = irandom(argument0);

if(spwn == 0)
{
  enemy = instance_create(irandom_range(0,room_width-32),irandom_range(0,room_height+32),obj_enemy);
  global.enemies_count++;
  with(enemy) {
  enemyx = enemy.x;
  enemyy = enemy.y;
  enemyid = global.enemies_count;
  }

  buffer_write(obj_network.buffer,buffer_u8,5);
  buffer_write(obj_network.buffer,buffer_u16,enemyid);
  buffer_write(obj_network.buffer,buffer_u16,enemyx);
  buffer_write(obj_network.buffer,buffer_u16,enemyy);
  network_send_packet(obj_network.buffer,buffer_seek_start,buffer_tell(obj_network.buffer));
}
}
any ideas about what's going wrong?
 
Last edited by a moderator:

TsukaYuriko

☄️
Forum Staff
Moderator
Make sure that none of the variables you are using are arrays. Output is_array using show_debug_message for each of them to check. This especially applies to everything you pass to the script as arguments.
 
B

Ben Hubble

Guest
Make sure that none of the variables you are using are arrays. Output is_array using show_debug_message for each of them to check. This especially applies to everything you pass to the script as arguments.
Thank you, but it turns out it was because I said in a with statement with enemy, enemyx = enemy.x & enemyy = enemy.y, after taking out enemy. from them, it worked! Now I can continue on my game :)
 
Top