How to embed Lua inside Python?

DangerOnTheRanger picture DangerOnTheRanger · Jun 4, 2011 · Viewed 13.3k times · Source

This sounds like a weird question, so I'll explain circumstances surrounding first.

Basically, I have a 3D game development kit, written in Python, that works excellently by itself. However, most of my users will be used to using Lua as a scripting language, so I started to look at Lua-Python bindings.

I settled with Stefan Behnel's amazing Lupa library. However, it basically requires end-users to know how to compile applications, which is unacceptable for my GDK. Also, I normally can only access a Linux system, and since my game development kit runs on Windows and Mac OSX, the Windows binaries always lag behind, and my OSX users must compile my GDK themselves.

Does anyone know another alternative? Thank you!

P.S: I've already tried Lunatic Python, and Lux is too outdated.

Answer

Hortinstein picture Hortinstein · Jun 4, 2011

you should look into lunatic-python it is a 2 way bridge between python and lua.

an example off the site shows how natural and easy it is:

>>> import lua
>>> lg = lua.globals()
>>> lg.string
<Lua table at 0x81c6a10>
>>> lg.string.lower
<Lua function at 0x81c6b30>
>>> lg.string.lower("Hello world!")
'hello world!'