Axe Lua

BlitzMax Forums/BlitzMax Programming/Axe Lua

does anyone have any example of calling a single function at a time from an lua script? ive been trying most of the evening with various success/fails and guessed someone must have done it already.

(searching the forum gave a few methods but im not sure they are exactly what im after)

get field( global table, function name )
...push arguments...
lua call( no. args, no. returns ) -> return values placed on stack when execution has completed


I won't get you the exact code, since it's relatively simple to read the manual and find it yourself (since I don't feel like finding it).

lua script:

function Teapot()
	return "im a lil teapot..."
end


bmax code:

Local vScript:TLuaScriptEngine = New TLuaScriptEngine

vScript.Reset()
vScript.RunScriptFile("Teapot.lua")

vScript.BeginLUAFunctionCall()
vScript.CallFunction("Teapot", True)

print vScript.GetResultString()


whats printed is garbage, this only happens for strings

Don't use the Lua script engine module. It's a piece of junk.

Seems that was the problem, I created my own system for handling the scripts and now all is fine.