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

Question - IDE Extensions argument types

Discussion in 'GameMaker Studio 2 Community Tech Support' started by xDGameStudios, Nov 23, 2019.

  1. xDGameStudios

    xDGameStudios Member

    Joined:
    Sep 15, 2016
    Posts:
    586
    Right now when building my own extension in the IDE I can only add arguments of type string and double.
    Is there a way to set an argument as an array? for example imagine I have an function:

    Code:
    array_to_list(array, [output])
    this function is supposed to receive an array as input and an optional output list. If no output list is supplied a new is created. How can I do this? Even if the IDE doesn't allow for that yet... is there a backstage way of doing stuff like this?

    Thank you for your time! :)
     
  2. kroart

    kroart Member

    Joined:
    Jun 16, 2018
    Posts:
    21
    Extensions can accept and return only strings and doubles and I don't know a way to pass an array as argument. And I also courious to get an answer) The only option I can see now - it's to parse a json formatted string with an json array in it. But this approach will give an extra performance impact because you need to fill ds_list, after you need to convert it into json string using json_encode() and then in extension you need decode this string back to json array object. For example JSONArray in java (if you write extension for Android), and there if you really need array and JSONArray will not suite you - you need to to create an array fron JSONArray. So this method should be very slow especially with big arrays.

    It's the only way I can see and I wonder to know a faster approach too)
     
  3. Mert

    Mert Member

    Joined:
    Jul 20, 2016
    Posts:
    428
    You can only pass double and string types to Extensions and from extensions as everything in GM are either double or string.
    You can, in fact, pass async events to GM from extensions, but only strings and doubles likewise
     
  4. kroart

    kroart Member

    Joined:
    Jun 16, 2018
    Posts:
    21
    Another approach is to create your own formatted string like “76;467;0.2;-765” and pass it into extension and there parse it into an array. I think it may be faster than solution with json formatted string but it should be tested for performance
     
  5. xDGameStudios

    xDGameStudios Member

    Joined:
    Sep 15, 2016
    Posts:
    586
    I should add that my current extension is a GML extensions so I'm not passing arguments back and forth to a dll.
    I just wanted to pack my scripts as an extension instead of a bunch of scripts.
    Does GMS2 crashes if I set argument type as number and pass an array instead?
     
  6. kroart

    kroart Member

    Joined:
    Jun 16, 2018
    Posts:
    21
    You can try it in your extension and write here how it works) It may be faster than trying to find someone who already knows the answer)
     

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