need help getting an error when my player collides with doors

yoavs12

Member
the error:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object doorway_obj:

Push :: Execution Error - Variable Index [4,0] out of range [4,-1] - 3.<unknown variable>(100027,128000)
at gml_Object_doorway_obj_Create_0 (line 6) - TargetRoom = ui_obj.map[ui_obj.ih,0];
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_doorway_obj_Create_0 (line 6)

when my collides with my door_obj the game crashes and gives me this error. i am using gms2.2.2.

door_obj:


GML:
pm="+";
       TargetRoom=ui_obj.map[ui_obj.ih,0]
       Targetx = 416;
       Targety = 448;
ui_obj:


Code:
 player_spawn_x=0;
      player_spawn_y=0;
      spawn_room_var=-1;
      iv=0;
      ih=0;
      randomize();
randomizer:


Code:
 ix=1;
      list_counter=0;
      room_list=ds_list_create();
       ds_list_add(room_list,room2);
       ds_list_add(room_list,room3);
       ds_list_add(room_list,room5);
       ds_list_add(room_list,room6);
       ds_list_shuffle(room_list);
        map = ds_grid_create(4,1);
        map[0,0]=room1;//spawn room
       while(ix < 4)
      {
        
            if(ix=3)
            {room_choosen=room4}//random room 1_D_L
            
    
              else{room_choosen=ds_list_find_value(room_list,list_counter)}// random room 2_D   
        

        map[ix,0]=room_choosen
        ix=ix+1;
        list_counter=list_counter+1;
       }
collision:


Code:
 var inst=instance_place(x,y,doorway_obj);
         if(inst!=noone)
        {
    with (ui_obj){
    Targetpm=inst.pm;
    if(Targetpm="+")
    ih=ih+1;
    if(Targetpm="-")
    ih=ih-1;
    spawn_room_var=inst
    player_spawn_x=inst.Targetx
    player_spawn_y=inst.Targety
    room_goto(inst.TargetRoom)   
      }
      }
any help will be appreciated
 

Nidoking

Member
The grid accessor is [# index, index]. You're trying to access a grid as if it were an array, and it probably doesn't make it less confusing that you called it "map".
 
Top