Get instance properties with instance id...

Discussion in 'Programming' started by Schwee, Sep 10, 2019.

  1. Schwee

    Schwee Member

    Joined:
    Jul 6, 2016
    Posts:
    165
    This feels obvious but I may be googling the wrong things...

    Create event in obj_ctrl:
    Code:
    members = ds_list_create();
    member = instance_create_layer(room_width / 4, room_height - 25, "PartyMembers", obj_member);
    member.name = global.main_member_name;
    ds_list_add(members, member);
    Create event of obj_profile:
    Code:
    member = ds_list_find_value(obj_ctrl.members, 0);
    name_width = texture_get_width(member.name);
    So I have the id of the instance I created previously...now I need to reference the contents of it...
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,455
    That's exactly how you're supposed to do it, pick it out of the list and then use the result on the left side of a variable referencing dot.

    If it doesn't work, either it's because global.main_member_name isn't actually a texture ID, or the instance of obj_ctrl is being created after the instance of obj_profile.
     
  3. Schwee

    Schwee Member

    Joined:
    Jul 6, 2016
    Posts:
    165
    ok i realized i meant to be doing string_width instead of texture_get_width...didn't read autocomplete properly heh, and then I jumped to the conclusion that I had only gathered the instance id which was not the instance itself. Let me give it a try, thanks!
     

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