Game Development Community

Torque + Lisp

by Joel Reymont · in Torque Game Engine · 01/26/2005 (12:45 pm) · 16 replies

Folks,

I'm not looking to answer a lot of "why Lisp?" questions, lets just say that I'll be using Lisp. I would like to create some TGE bindings and go from there. I understand that a Python integration has been done but I could not find the sources anywhere.

I'm looking to build Torque as a shared library and separate initialization and finalization code into a couple of functions. Is this doable and straightforward? It will be easier to call Torque from Lisp than to call Lisp from Torque.

Would you point me to any example initialization code? Would you know where the Python bindings are?

Note that I'm not looking to do a 3D game at all. I'm creating online poker software and bought Torque for its networking layer and the ability to draw GUI controls using OpenGL. The poker room scene is a bunch of bitmaps (carpet, table, chairs, cards, chips, etc.) and a few Torque buttons and text fields.

Thanks, Joel

#1
01/26/2005 (12:58 pm)
TGEPython lives HERE . I think it's a pretty good example of binding another language to Torque via the console system (which TorqueScript shares). TGEPython is being used in production by our company... I have improved it quite a bit in the last few weeks...

I would highly suggest driving Torque with TorqueScript... only, creating minimal interfaces between your "real language" and it... for instance, we don't use ANY of the SimObject stuff in TGEPython...

I also created PyTorque which was Torque compiled into a shared library... no problems with this... writing glue code/swigging/whatever sucks though... just communicate through the TGEConsole.

-Josh
#2
01/26/2005 (1:26 pm)
Josh,

Thank you very much for the pointer. Please clarify something for me...

I thought the whole purpose of binding Torque to something like Python or Lisp is to drive it with those languages. Are you saying that you are using TorqueScript _as well_ as Python?

I must be missing something but is there a C++ "TorqueScript" class that you bind to, if not then how do you create interfaces between Python and TorqueScript?

I would like to implement the TorqueScript functions as opposed to creating bindings for the whole of TGE. I think this should let me drive Torque with Lisp.

Thanks, Joel
#3
01/26/2005 (1:29 pm)
Josh,

Thank you very much for the pointer. Please clarify something for me...

I thought the whole purpose of binding Torque to something like Python or Lisp is to drive it with those languages. Are you saying that you are using TorqueScript _as well_ as Python?

I must be missing something but is there a C++ "TorqueScript" class that you bind to, if not then how do you create interfaces between Python and TorqueScript?

I would like to implement the TorqueScript functions as opposed to creating bindings for the whole of TGE. I think this should let me drive Torque with Lisp.

Thanks, Joel
#4
01/26/2005 (1:30 pm)
I'm looking to do simple stuff like displaying billboards (drawing bitmaps through DGL?) and TGE GUI controls as well as sending and receiving packets over the network.
#5
01/26/2005 (1:42 pm)
I use Python for the bulk of the game logic and to interface to a number of packages we use.

I use TorqueScript for all GUI stuff (with callbacks to Python on actions), datablocks, and (most of the ) engine steering.

I keep the intefaces between the two to an absolute minimum.

It's certainly possible to rewrite all the TorqueScript. It's a substantial time commitment though... and really we wouldn't be gaining much/anything... in short, Torque is great and TorqueScript is adequate to steer it...

-Josh
#6
01/26/2005 (2:06 pm)
Joel, you will be very interested in Torque2D when it comes out as it is exactly what you want to do.
#7
01/26/2005 (2:09 pm)
I'm looking to do simple stuff like displaying billboards (drawing bitmaps through DGL?) and TGE GUI controls as well as sending and receiving packets over the network.
#8
01/26/2005 (2:11 pm)
@Pat: Does Torque2D plug into Torque?
#9
01/26/2005 (2:33 pm)
Pat, I can't wait for Torque2D, I have a March 10 deadline :-).

Josh, is it easy to call back into Python from TorqueScript? Any tips that you would want to give me?

Thanks!
#10
01/26/2005 (2:38 pm)
It's very easy....

In Python:

TGEExport(PyZoneTrigger,"Py","ZoneTrigger","desc",3,3)

In TorqueScript:

Py::ZoneTrigger(%trigger,%object);

I also added a neat way to "exec" python code from TorqueScript too:

PyExec("./rpg/some.py");

This isn't totally necessary, but I like to PyExec from .gui files to keep things a bit organized.

-Josh
#11
01/26/2005 (2:41 pm)
@Guys: The T2D engine is currently setup to render its scenes to a custom TGE Gui Control called fxSceneWindow2D. You can run an unlimited number of scenes/windows. It runs on stock TGE without modification.

- Melv.
#12
01/26/2005 (2:43 pm)
@Melv: Holy cow!!!! Now, I can't wait for T2D!!!! I have a lot of GUI stuff to do!!!!
#13
01/26/2005 (3:42 pm)
Josh, you said you've made some updates to TGEPython. Do you have anything newer than the 1.0a version?
#14
01/26/2005 (4:12 pm)
Josh, I looked at TGEPython and it looks to me like you are basically calling Python from TGE. I think I'll have to go the other way around and let Lisp initialize TGE and call the main loop functions. It's quite hard to invoke Lisp from TGE when you are not given an entry point.

I'll post my findings here and to http://wagerlabs.com/tech . I have gone through a number of tool permutations to find one that gives me OpenGL widgets, solid UDP networking and Lisp. I hope this is it!
#15
01/26/2005 (4:28 pm)
@Steven: If I ever get time I'll release a new TGEPython version... won't be anytime soon, sorry

@Joel: TGEPython is bidirectional
#16
01/26/2005 (5:09 pm)
Joel, cool stuff. Check your inbox for the address listed in your profile when you get a chance. :)