Axe Lua

BlitzMax Forums/BlitzMax Programming/Axe Lua

Snixx(Posted 2007) [#1]
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)


N(Posted 2007) [#2]
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).


Snixx(Posted 2007) [#3]
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


N(Posted 2007) [#4]
Don't use the Lua script engine module. It's a piece of junk.


Snixx(Posted 2007) [#5]
Seems that was the problem, I created my own system for handling the scripts and now all is fine.