如何将Lua嵌入Python? [英] How to embed Lua inside Python?

查看:273
本文介绍了如何将Lua嵌入Python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这听起来像是一个奇怪的问题,所以我先解释一下周围的情况.

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

基本上,我有一个用Python编写的3D游戏开发套件,该套件可以很好地工作.但是,我的大多数用户都习惯于使用Lua作为脚本语言,因此我开始研究Lua-Python绑定.

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.

我选择了Stefan Behnel令人惊叹的 Lupa 库.但是,它基本上要求最终用户知道如何编译应用程序,这对于我的GDK是不可接受的.另外,我通常只能访问Linux系统,并且由于我的游戏开发工具包可以在Windows和Mac OSX上运行,因此Windows二进制文件始终滞后,并且OSX用户必须自己编译GDK.

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:我已经尝试过Lunatic Python,而Lux太过时了.

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

推荐答案

您应该查看 lunatic-python 这是python和lua之间的两通桥.

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!'

这篇关于如何将Lua嵌入Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆