Open tabularelf opened 4 months ago
Honestly if variable_clone(argument)
or array_copy([], 0, argument, 0, argument_count)
just worked I wouldn't mind handling the more niche cases on my own. However once array_copy
is supported, most people will begin to ask for all the other array functions, doing just variable clone would avoid this issue, and still open it up for more use cases over all.
Is your feature request related to a problem?
Sometimes it'd be nice to take the contents of
argument
and pass it straight into array functions for processing, as it isn't super fast or as convenient in some cases.Describe the solution you'd like
The new function
argument_array_copy([srcOffset], [srcLength], [destArray], [destOffset])
, will copy the whole argument array within the current function scope, into a GML array. If the target GML array is not big enough, it will be resized accordingly to fit in the argument contents.The arguments go as follow:
srcOffset
- Offset of the arguments to start copying from. Defaults to0
srcLength
- Length of the arguments to copy up to. Defaults toargument_count
destArray
- Array to copy the contents into. Defaults to a new GML arrayarray_create(srcLength-srcOffset)
destOffset
- Offset to paste copied arguments. Defaults to0
(just likesrcOffset
)Example:
Describe alternatives you've considered
argument
array, which is slow. Especially for big argument counts.Looping
Passing in an array of values
Additional context
I had previously discussed this with Russell on Discord about possibly allowing to pass
argument
directly to array functions, without creating an array loop. Due to complications, it was instead suggested to be a function that can copy the argument array, as a GML array. Though, seeing that I can't find an existing feature request, I decided to make one.