• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - IDE Extensions argument types

xDGameStudios

GameMaker Staff
GameMaker Dev.
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! :)
 

kroart

Member
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)
 

Mert

Member
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
 

kroart

Member
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
 

xDGameStudios

GameMaker Staff
GameMaker Dev.
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?
 
Top