What is the default value meaning of -2 in GML?

Discussion in 'Programming' started by brownlee219, Dec 3, 2018.

  1. brownlee219

    brownlee219 Member

    Joined:
    Nov 12, 2016
    Posts:
    8
    Hello,
    Can anyone tell me what the -2 default value is for GML? Like -4 means that there isn't an instance id. What does -2 mean? Thanks!
    I getting this error:

    ############################################################################################
    FATAL ERROR in
    action number 6
    of Step Event0
    for object obj_enemy_peasant:
    Push :: Execution Error - Variable Get -2.repair_list(100242, -2147483648)
    at gml_Object_obj_enemy_peasant_StepNormalEvent_6 (line 98) - ds_list_delete(target.repair_list,ds_list_find_index(target.repair_list,id))
    ############################################################################################
     
  2. Yal

    Yal Member GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,250
    -1 is self, so I'm imaging -2 is other. (-4 is noone, as you said). Not sure what global is, but given the pattern, let's just guess it's -3? :p
     
  3. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,003
    Pretty close, -3 is all, -4 is noone, and -5 used to be global (deprecated for some time now). Then there were -6 and -7 for local variable scope that were never documented and were already removed as of GM:S.
     
  4. brownlee219

    brownlee219 Member

    Joined:
    Nov 12, 2016
    Posts:
    8
    Thanks! I think you're right. I needed to use other.id to get it working. Also, isn't -5 global?
     
  5. Yal

    Yal Member GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,250
    It was before, it's deprecated now, so it might be unavailable depending on the version of GM you're using:
    ...then again, using these magic numbers instead of the human-readable constants is just inviting disaster.
     
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    5,647
    The mmagic numbers do pop up in error messages. -5 is still global in the errors.
     
  7. Yal

    Yal Member GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,250
    What, they still do? <__< (I write so good code these days I don't get error messages very often, so I'm outta the loop with what they're actually saying)
     

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