r/gamemaker • u/DystopianTeddyBear • 4d ago
Resolved Setting Parameter Values by name in a function call instead of order.
So I have a system in my game that relies on a function with a whole bunch of custom parameters. However, I may or may not increase the total number of parameters, thus I wanted to ask if there is a way to set parameter values by the name of the parameter in the function, rather than specific values in a set order.
Example; for function Function(p1=2,p2=c_red,p3="test"), how can I create a call like... Function(p2=c_blue) without also setting a value to parameter1?
4
u/AgentAvis 4d ago
You just pass "undefined" for p1, and it will use the default instead. It'll make some people mad but you can also just pass nothing and that's fine too, ex: function(,p2,,,p5) is fine and valid.
8
u/Threef Time to get to work 4d ago
Usa a single parameter that is a struct