1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 Undefined variable that IS defined

Discussion in 'Programming' started by William Garrison, Dec 1, 2019.

  1. William Garrison

    William Garrison Member

    Apr 16, 2019
    Undefined variable 'door1' referenced in room rHouse_01 in instance inst_67C21C7D's variable 'dev_what'

    dev_who = 0;
    dev_what = 0;
    with (dev_who) {
        dev_what = true;
    VARIABLE DEFINITIONS (defined in the room are)
    dev_who = 0; (resource: set to oBoss)
    dev_what = 0; (resource: set to door1)

    Basically im trying to make a simple button that I can reuse to test certain triggers in the room triggering events that fire when a false is made true.
  2. Catastrophe

    Catastrophe Member

    Sep 22, 2019
    Edit: nvm, looking at this again, didn't realize it was an issue with variable definitions at first

    You do have a resource named door1 right? It's not oDoor1 or something? Because it will consider it a variable if it can't find the resource. E.g. I get that error if I choose a resource, and then delete that resource afterwards and build the game
    Last edited: Dec 1, 2019
  3. TheouAegis

    TheouAegis Member

    Jul 3, 2016
    Wait, is dev_what a resource or a bool?

    If a variable holds a resource, always set it to noone by default. A value of 0 is always a valid resource ID.
  4. samspade

    samspade Member

    Feb 26, 2017
    My guess it is a scoping issue - e.g. whatever object 0 is in your resource tree doesn't have dev_what defined. Also you shouldn't use with like that. It theoretically works but it relies on both your resource tree order and the underlying workings of game maker.

    You could always run it with the debugger and see if that object has it defined.

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