Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Well for C++ written games using Lua scripts for easy changing ai, quets etc is very reasonable and it's common. However now I'm going to write a game in pure python and I don't know if I should use Lua. Python itself is very high level script language. However, there are things to consider why I could use lua scripts:

  1. Lua is commonly used for game scripting and other people who will work with me know Lua and don't know python

  2. Python module to embed lua code into python uses very fast JIT compiler so the lua code actually would be much faster than python code (big plus for AI)

  3. It would separate the game engine itself (Python) from the scripted logic (Lua)

Do python games use Lua? Is it a resonable thing or I should just stick to pure python? I need some advice because I have no idea.

share|improve this question
1  
Lua can benefit greatly from LuaJIT. BTW –  Egor Skriptunoff Feb 15 '13 at 21:10
    
@Egor Skriptunoff I know, that's a big reason to use Lua scripts for python game. The lua module for python uses LuaJIT2 ( pypi.python.org/pypi/lupa ) –  user1873947 Feb 15 '13 at 21:12
1  
Why does it matter whether other people's python games use Lua? –  Trevor Powell Feb 15 '13 at 23:42
1  
That seems rather a bizarre claim to make. Of course they can be wrong. There are major industries which only exist because of millions of flies being wrong. Popularity is only a measure of popularity; it's mostly orthogonal to properties like 'utility' or 'efficiency', or etc. –  Trevor Powell Feb 16 '13 at 0:05
5  
If Lua is that fast, then what is the point of using Python at all? –  krzat Feb 16 '13 at 0:14

2 Answers 2

up vote 7 down vote accepted

Do python games use Lua?

Generally? No.

Is it a resonable thing or I should just stick to pure python?

Define "reasonable"?

Python has been used in many game development scenarios. While Lua may be well known among some game mod circles (like WoW GUIs, Garry's Mod, and so forth), Python was the language of choice for Civilization IV modding. So it's not like the language is unknown among game modders in general.

If the people working with you don't know Lua, then a larger question is this: why aren't you writing the engine in Lua to begin with? I mean, if Lua code is going to be faster than Python code due to JIT, why would you not want the entire codebase to be in Lua?

It's strange that you've gather together this group of Lua programmers to make a game... in Python.

If you're doing it that way because Python has access to modules that Lua doesn't, then I would suggest using your Python->Lua bridge to give Lua access to those modules and let your Lua scripts do most of the heavy lifting. You'll be able to use the rest of your team as more than just game scripters. And Lua already has plenty of mechanisms for encapsulating scripts, so there's no trouble with sandboxing AIs from the rest of the engine.

That is, write a thin wrapper around your needed Python modules, expose it to Lua, and transfer most of the engine into Lua script. From there, use your Lua scripts to execute potentially user-scripts as needed.

However, if you don't want to do that (presumably because you don't want to code in Lua), then you can stick with your original plan. There's nothing wrong with it per-se; it's just odd to have a script-based engine call a faster script-based scripting system. Generally speaking, it's the core engine stuff that needs performance the most; the AI scripts don't need it as much.

share|improve this answer
    
I'd say depending on said AI. I've seen very simple games with very sophisticated logic. Chess, for example. –  Bartek Banachewicz Feb 15 '13 at 23:05
    
@BartekBanachewicz: Yes. It's almost like I said "Generally speaking". ;) –  Nicol Bolas Feb 15 '13 at 23:08
2  
Is it bad to show an example that breaks the generality? –  Bartek Banachewicz Feb 15 '13 at 23:09

I think it makes perfect sense. If Lua can benefit from (PyPy?) python JIT, even better. Lua is much easier for beginners, which means more community mods. It also makes it very easy to separate it from main code, as you said.

I see no reason for not doing it.

share|improve this answer
    
actually it's LuaJIT2 (see pypi.python.org/pypi/lupa ) and not python JIT. Thank you for the answer. I think I will wait for more answers to see what people think on it. –  user1873947 Feb 15 '13 at 21:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.