Sample BlitzMax + Lua?

Started by Yue, July 04, 2017, 16:59:12

Previous topic - Next topic

Yue

 :-X

Hi,
I'm trying to understand this, but I can not understand it, any suggestions on how to use Lua and BlitzMax?

https://en.wikibooks.org/wiki/BlitzMax/Modules/Other/Lua_Core#Running_Lua_Scripts_From_Within_BlitzMax

therevills

Hey Yue, check this thread out:

http://wasted.nz/posts.php?topic=85952


(Wow that took too long to find!  :o)

markcwm

#2
I think Yue solved his own problem over on Discord. I've never used Lua myself.
QuoteOk, no problem, here run script. :)
Code (blitzmax) Select
Local LuaState:Byte Ptr = luaL_newstate()
luaL_openlibs(LuaState)

lua_pushstring(LuaState, "BMXString")
lua_setglobal (LuaState, "luaglobal")

Function BMXName:Int (LuaState:Byte Ptr)
Local int_value:Int = luaL_checkinteger(LuaState, 1)
Local str_value:String = luaL_checkstring(LuaState, 2)
Print int_value
Print str_value
Return 0 ' number of values returned to Lua
End Function

Function Inc(LuaState:Byte Ptr )
Local file:String = luaL_checkstring(LuaState, 1)
luaL_loadfile(LuaState,file)
Return 0
End Function

lua_register(LuaState, "luaname", BMXName)

luaL_dofile(LuaState,"Hola.txt")
lua_close(LuaState)