Just in case someone stumbles across a similar issue:
Expressions can only return one value. If you want multiple return values you need to use a functions as action/condition and make use of the Copy variable into parameter action. Walkthrough is in Post#20.
Hey there, I was building some more hex grid based logic and once again I am hitting a wall with the way external functions are setup.
So generally speaking I have inputs like X, Y, Size, Radius, flattop/pointytop, Distance. That I can setup as parameters nicely. There are a couple of things that I want to calculate, but lets stick with the basics: get (q;r) from (x;y;size;orientation)
GDevelop expressions only return one number/string/bool. But I need both cords from one expression. Here is why:
A function, which calculates q, also needs to caluclate r, in order to properly round. That is totally fine, if my application is an Action, as in the “Hex 2D Grid” Extension from D8H. There an action sets the position of an object to the grid. Actions can do that. But I need thos values for further calculations. Therefore I want to make an expression.
It is possible to just create a bigger function and include all my calculations in there, but that is not modular at all.
If I create two separate expression for q and r, I need to do exactly the same calculations twice, because of the way how q and r are interrelated with each other.
There is one solution, that I found, which is to make an expression which only calculates q from (x;y;size;orientation) and saves r in an extension variable. If I need r I can access it simply by returning it. That is not pretty at all, and more of a workaround.
Has anyone a nicer solution that I am not seeing? (I am happy to keep most of my calculations inside the extension and only return something like a string “q;r” to the event sheet, but at least inside my extension I want to be able to have the system modular)






