moonsharp icon indicating copy to clipboard operation
moonsharp copied to clipboard

Added support for converting to and from System.Tuple.

Open Michael-Kelley opened this issue 9 years ago • 2 comments

To send a Tuple to Lua, simply pass it as a global. ie: script.Globals["a_tuple"] = Tuple.Create(1, 2, 3);

You can then unpack it in Lua normally: local a, b, c = a_tuple

To return or set a Tuple from Lua, just surround the tuple values in curly braces: some_clr_class.some_tuple = {42, 'the meaning of life', true}

If you would like to get a Tuple from a DynValue, you can use the generic TupleOf methods: var aTupleFromLua = dynValue.TupleOf<int, string, bool>() // returns a System.Tuple<int, string, bool>

Michael-Kelley avatar Oct 25 '15 17:10 Michael-Kelley

This is a nice feature to have. Any chance of it getting it included?

Or is there a workaround to allow local a, b, c = a_tuple in Lua to work with MoonSharp?

AidanMcK avatar Feb 27 '21 13:02 AidanMcK

@AidanMcK Need to get the conflicts resolved and then will merge, I will take a look in a bit.

LimpingNinja avatar Nov 22 '21 20:11 LimpingNinja

that sure is a long bit

milenakos avatar Apr 23 '23 16:04 milenakos