diff --git a/luad/lfunction.d b/luad/lfunction.d index 4fd6e92..d3d987f 100644 --- a/luad/lfunction.d +++ b/luad/lfunction.d @@ -67,6 +67,35 @@ struct LuaFunction return callWithRet!T(this.state, args.length); } + /** + * Call this function using an array. + * Params: + * T = expected return type. + * args = list of arguments. + * Returns: + * Return value of type $(D T), or nothing if $(D T) was unspecified. + * See $(DPMODULE2 conversions,functions) for how to + * catch multiple return values. + * Examples: + * ------------------ + lua.doString(`function answerD(question, a, b, c, d) print(question) return d end`); + auto answerD = lua.get!LuaFunction("answerD"); + + auto params = ["How many letters are in the alphabet?", "5", "20", "10", "26"]; + + auto answer = answerD.call!int(params); + assert(answer == "26"); + * ------------------ + */ + T call(T = void, U)(U[] args...) + { + this.push(); + foreach(arg; args) + pushValue(this.state, arg); + + return callWithRet!T(this.state, args.length); + } + /** * Set a new environment for this function. *