1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GML [Solved] Reading room data, but not the current room

Discussion in 'Programming' started by Electros, Mar 16, 2019.

  1. Electros

    Electros Member

    Joined:
    Jul 19, 2016
    Posts:
    320
    Hi - the basic premise is that I am trying to;

    1. Create rooms as individual chunks.
    2. Iterate through the desired rooms, and save the data (instances, x, y for now) in each to a data structure (e.g. ds_list, ds_grid)
    3. Create these chunks in the current room when called upon, using the saved instance and positioning data

    I'm falling down currently on section 2 - I thought I would be able to use room_add() to create a room, then room_assign() to load room data in, read out and save whatever data I need, and work through the chunks. The below code is giving me 0s for everything.

    Code:
    //Create the logging variables
    var pRoomWidth = 0;
    var pRoomHeight = 0;
    var pRoomInstanceCount = 0;
    
    //Create the parser room
    parserRoom = room_add();
    
    //Assign the chunk data to the room
    room_assign(rm_Game_Chunk_1, parserRoom);
    with(parserRoom)
        {
        pRoomWidth = room_width;
        pRoomHeight = room_height;
        pRoomInstanceCount = instance_count;
        }
    show_message("Dimensions: " + string(pRoomWidth) + ", " + string(pRoomHeight));
    show_message("Instance Count: " + string(pRoomInstanceCount));
       
    //Assign the chunk data to the room
    room_assign(rm_Game_Chunk_2, parserRoom);
    with(parserRoom)
        {
        pRoomWidth = room_width;
        pRoomHeight = room_height;
        pRoomInstanceCount = instance_count;
        }
    show_message("Dimensions: " + string(pRoomWidth) + ", " + string(pRoomHeight));
    show_message("Instance Count: " + string(pRoomInstanceCount));
    Should this method even work, i.e. am I meant to be able to access and pull data out of a room created and then assigned which isn't the current room, in which case how would I go about that?

    Or is there a better way I could / should be going about reading room data not from the current room? My other thought was to setup a persistent logging object which then went through each room chunk and logged the data as it went. Could be done once on game load.

    [Edit: Solved - went for the logging object method that flicks through all the target rooms recording the required data on game load]
     
    Last edited: Mar 19, 2019

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice