Lua for Blitz

Blitz3D Forums/Blitz3D Userlibs/Lua for Blitz

Hi all there,

i have just created a decls for the Lua scripting language.
In the package there's the userlib, some helperfunctions,
the dll and a little blitz example.
Get it from my site below.
-----------------------------------------------------
Updated to BlitzLua 1.1B
Added some Lua constants
Functions for retrieving values from tables

---------------------------------
http://www.moonworx.de

Great, thanks! :)

Regards - Xaron

Nice - Thanks - will give it a try !

I'm getting it right now :D
This may be quite useful...

Argh... You're using one of those cursed download sites!


Do you have any bigger examples of its useage... to, uhm... help this thickheaded oaf?

Ouch, haven't looked in the code since posting. The bad thing is i don't know how we could call a blitzfunction from within a lua script. I had a look in the BMax forum, where there are some more usage examples. You should get yourself the header- and sourcefiles from www.lua.org and have a look in the programmers handbook available online. Sorry, but i don't know much more about this right now.
Include "BlitzLua.bb"

; creates a lua state, sort of runtime environment
; every lua function must provided the actual lua state
l = lua_open()
; includes the base library in lua
luaopen_base(l)
; includes the io library
luaopen_io(l)
; includes the string library
luaopen_string(l)
; includes the math library
luaopen_math(l)
; this calls a script
LUA_callScript(l, "hello.lua")
; try to find the expression <foo> in the script
; global might be a Function or variable
LUA_getGlobal(l, "foo")
; this will actually perform the script
; we call the function foo with <0>  zero parameters and
; want get <1> one result							
lua_call( l, 0, 1 )
; print the result as string
Print lua_tostring(l, -1)
; and pops it from the lua stack
LUA_pop( l, 1 )
; now we have finished and close the state
lua_close(l)

WaitKey()
End

-----------------------------------------
www.moonworx.de

Okay, a bit of fiddling has told me that this is probably exactly what I need.

You have participated in the future of the universe!
Thanks :)

Today i received an interesting e-mail that pointed to the following code in the archives:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1009

With this code you are able to call Blitz functions from C++, so why not from Lua since you can call C functions.
If someone is C/C++ capable, he might have a try with calling Blitz3D functions from within Lua. I think you must embed a function that registers the Blitz3D functions at startup from this dll.

Btw. thank you for all input so far.

---------------------------
www.moonworx.de