Embedding the Python Interpreter in Games

Started by
11 comments, last by Exellon 21 years, 8 months ago
Is this possible, or would it even work? Would it be beneficial?
Advertisement
Check out SWIG.

-------
Andrew
quote:Original post by Exellon
Is this possible, or would it even work? Would it be beneficial?


Depends, depends, depends.

It would help to know which language you''re willing to embed Python into, how and what for, and what you''re expecting to do with it.

Python can be embedded, but wasn''t meant to be. It means it is not the easiest interpreter to embed (nor the hardest one, for that matter). Now if all you''re willing to do is run Python scripts from your C program, it''s very easy. If you need both languages to interact, it gets tougher. If you want to map C++ classes to Python objects, it becomes quite harder.

Hope this helps.
Well can anybody think of a language that would be easy to embed with C++ and interoperate with C++ classes?
You can consider LUA (its the easiest to embed I''ve ever seen), but its not object oriented.
http://www.lua.org , combined with SWIG or any of the other binding generators.


Don''t listen to me. I''ve had too much coffee.
I''ve been playing around with Simkin on a simple game project in my spare time. It is really easy to make an object sciptable. It''s not perfect, but I had it hooked up to a gameobject and was controlling it through scripts in short time.

You have to email to Simon with a request for Simkin - but you get the source and all - you can''t beat it.

Dave "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
There''s a library available in Boost that lets you use C++ classes in Python.

Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee

[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ]

[Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)]
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:Original post by blueEbola
You can consider LUA (its the easiest to embed I''ve ever seen), but its not object oriented.

But it can simulate object-orientation quite easily, and ends up looking very similar to Python or java-script. Which is nice. You just have to have some discipline when using it.



[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
quote:Original post by Kylotan
But it can simulate object-orientation quite easily, and ends up looking very similar to Python or java-script. Which is nice. You just have to have some discipline when using it.


Yeah, I've actually done something like that before when I was giving LUA a test drive. The resulting object constructor isn't that pretty though

LUA is very extensive, using its tag methods you can simulate operator overloading on an object (table).



[edited by - blueEbola on August 17, 2002 5:58:21 PM]

This topic is closed to new replies.

Advertisement