Pike: Integration with C++?

DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #1
I was looking the whole day, searching for something on how to integrate the pike scripting language with C++ to be used as a game script language. Found nothing (only sth about sth called CMOD, not really helpful), so any pointers (no pun intended) are appreciated.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
That's the problem with Pike unfortunately... nice language, no docs on integration with C.

Go with Lua or Ruby instead. Nice languages both (though for somewhat different purposes), and easy, well-documented APIs.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #3
That, ummm, sucks.

I will try to contact the Pike dev's on this. The project that this is needed for will eventually be fully documented, including Pike integration, if it is possible after all.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #4
In the meanwhile, since these dudes seem a little inaccessible, any other languages with C++ integration possibilities? How is that with Python, Lua, Ruby?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #5
For lua look at OSC's uDG entry for last year. For Ruby look at his entry for this year. Blush Do we see a theme?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
Both Lua and Ruby are very easy to integrate with C/C++, Ruby's easier to translate OO between the languages, but it just depends what you want to use the scripting language for.

Mail me if you need source/example projects.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #7
Quote:Originally posted by OneSadCookie
Both Lua and Ruby are very easy to integrate with C/C++, Ruby's easier to translate OO between the languages, but it just depends what you want to use the scripting language for.

Mail me if you need source/example projects.

We have also made Lua and Ruby final candidates, no success with contacting the Pike dudes.

Ruby seems to be working with SWIG nicely, though I have not tried it myself, but the other guy on the project got it to run.

As for Lua, it is still a pain. I got a Lua VM working, no problem executing script files, but I have yet to do the C++ integration. Tolua++ doesn't work, it seems to have no hang on namespaces. Even though it compiles, and I can load my lib to the Lua VM (in this case just a test Vector3D), and it seems like the namespace and class are there (the tables exist), but I cant create an object instance.

Today, I will see what luabind brings, though the compilation of that was already a little shaky.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
Yeah, Lua isn't great for OO stuff... you probably don't want Vector3D to cross the language barrier anyway though Wink

As I said before, it just depends what you want to use the language for. Ruby's a great language for writing large amounts of high-level code very quickly in. You could quite happily put all your game logic and higher-level event handling, object management, UI, &c code in Ruby and just leave C/C++ for the low-level performance-sensitive stuff.

Lua's good for being a small scripting language... simple responses to events, for example... but it's not great for high-level stuff where you really want good object orientation. It has the advantage though that you can easily make sure that scripts can't harm anything, and that you can have multiple interpreters simultaneously.

I really wish Pike had a better API / docs to become a sort of halfway house... but it looks like that'll be a wee way off yet.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #9
You didn't happen to use luabind for your bindings, did you? I had no success with it, looked through all the examples, made a really simple test (just a constructor is bound), yet it doesn't compile (though, right now, not even vector<>::iterator compiles).

Luabind seems to be quite nice, though, much cleaner and efficient than tolua++. Too bad none works.

We want to use lua as a general scripting language, potentially ranging from game logic scripting to AI, possibly UI scripting, and more. Though, all of the UI will be contained with a single OpenGL view, so far. Thinking about it, since all graphics will be in a hierarchical tree, drawing themselves, it might be possible to script large parts of the UI.

So long, I have to get the whole Carbon OpenGL thingy working, can't do it in Cocoa this time Sad
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
I'd say Ruby is a better bet for such large-scale scripting.

I never used any automatic binding stuff for lua, I did all the bindings myself... particularly binding classes seems quite difficult, since Lua doesn't directly have the concept of a class.

Does SWIG not have a Lua back-end?
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #11
Quote:Originally posted by OneSadCookie
Does SWIG not have a Lua back-end?


No. Ruby and Python have, among others.
Quote this message in a reply
Post Reply