GML [SOLVED] Object.coords not accepted? (Acts like object doesn't exist)

Discussion in 'Programming' started by Dr_Nomz, Jul 21, 2019.

  1. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    590
    I'm trying to use a console to spawn in an object, and if the arguments provided don't have specific coords (x and y aren't sent through the console) it'll spawn at the Character's position instead.

    I've used this same type of thing before many times but now here for some reason it acts like the object doesn't exist, even though it clearly does.

    The weird thing is it knows that it's own object exists, obj_console, and it'll gladly accept those coords when spawning the item, but not for the player character.

    Code:
    action number 1
    of  Step Event0
    for object obj_console:
    
    Unable to find any instance for object index '0' name 'obj_Character'
     at gml_Object_obj_console_StepNormalEvent_1 (line 30) -       instance_create(obj_Character.x,obj_Character.y,obj_1); }
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Object_obj_console_StepNormalEvent_1 (line 30)
    That's the error I get when I try to use this code:

    Code:
          var obj_1 = asset_get_index(console_value(_console,1));
          if(obj_1 > -1){
          instance_create(obj_Character.x,obj_Character.y,obj_1); }
    Basically it spawns the object based on it's name in the index, but the coords are the issue here. When I use these, it just throws an error like obj_Character doesn't exist. Any idea why?

    This is the console I'm using if it helps:
    https://marketplace.yoyogames.com/assets/1356/developer-console
     
  2. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    136
    Are you 100% sure? Because if an instance of obj_Character does indeed exist, then this is either a bug or there are other factors at play.
     
  3. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    590
    I just tested it in another object, it worked just fine. Don't know why this won't find the object...

    Oh, I tried to use the create event to set the character's position, and it remembered where it was when it was created in the first room, but not the next one.
     
  4. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    590
    update: I think it's because the stupid console is "disabling" everything, and that for some reason makes it impossible to find the damn thing. Is there any way around this or no?
     
  5. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    136
    You'll have to be more specific in what you mean by "disabling" and why the console does it.
     
  6. Rukiri

    Rukiri Member

    Joined:
    Sep 25, 2016
    Posts:
    141
    Does "obj_Character" exist?
    I don't see a reason as to why you're getting an error...
     
  7. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    590
    Eh nevermind, instance_deactivate_all was necessary for the thing to work at all, so I just worked around it by having it create an object that runs the code I need AFTER the console is closed, so it worked out. Thanks for your time though.
     

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