1. Hey! Guest! The XXX GMC Jam will take place between August 24th, 12:00 UTC (Friday noon) and August 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Room instance order error

Discussion in 'Programming' started by jonjons, Aug 10, 2018.

  1. jonjons

    jonjons Member

    Joined:
    May 10, 2017
    Posts:
    197
    hello
    i have an instance obj_plrGui that creates a few global vars
    if i delete the instance from the room editor and create it from the room creation code all the other instances
    seem to crash for example "obj_damageTest" and other instances crash even with no code in their events

    ERROR!!! :: ############################################################################################
    FATAL ERROR in
    action number 1
    of PreCreate Event
    for object obj_damageTest:


    global variable name 'inv_items' index (100101) not set before reading it.
    at gml_RoomCC_room_00_4_Create (line 2) - addToGrid = global.inv_items;
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_RoomCC_room_00_4_Create (line 2)

    in the room creation code iam using
    if ( ! instance_exists( obj_plrGui ))
    {
    instance_create_depth(192, 64, depth, obj_plrGui);
    }

    My room only seems to work with the obj_plrGui on top of all other instances
    But i cant understand why obj_damageTest crashes with an error with no code in its events.

    Is there a way to make this work ? or create the instance obj_plrGui on top of all other instances ?
    thanks
     
  2. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    2,547
    The room creation code is executed after every object creation code.
    If your objects are persistent, you may create a room before this room and let them spawn it the creation code of that room.
    And then move to the new room.
     
  3. jonjons

    jonjons Member

    Joined:
    May 10, 2017
    Posts:
    197
    thanks ive moved all the persistent objs containing global vars to my frist room Menu, it seems to be working now.
    Problem now is to read all the load.ini files of these objects to a load game section.
    otherwise the player keeps getting overpowered
     

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