Scripting language for C game
Is there a way to easily combine a scripting language with C? I want to be able to call C functions that I right thru the scripting language and vice versa. Is it even possible to call your own C functions from a scripting language?
What is the ultimate answer to Life, the Universe, and Everything?
Yes . . .
. . . That's what scripting languages are all about. I learned how to do it initially from a book called Game Scripting Mastery (not Mac-oriented, but still applicable, and all C). This subject has been beat up plenty already. Search the forums for more info on how to do it.
Im not sure why those two are trying to make you feel like youve asked a silly question, but take it from me you havent. Doing that kind of thing can really improve the efficency of writing a game (think compile & test vs quit & test
)
This is a great language for exactly that purpose
http://www.lua.org/
Its really easy to get set up with, and you can integrate it with your game engine for speed & efficiency.
This game I wrote
http://fax.twilightcoders.net/N0x35C49E/
the engine is C and the game logic is lua, it worked out really well. (and the source code is available as well)
)This is a great language for exactly that purpose
http://www.lua.org/
Its really easy to get set up with, and you can integrate it with your game engine for speed & efficiency.
This game I wrote
http://fax.twilightcoders.net/N0x35C49E/
the engine is C and the game logic is lua, it worked out really well. (and the source code is available as well)
Sir, e^iπ + 1 = 0, hence God exists; reply!
We use C with Lua too.
Have a peak at the innards of this _ iFly_Universal012207app.zip
Somewhere on lua.org is a list of products using it, astounding.
Did I see that 70% of Adobe Lightbox is coded in LUA? I think so.
Have a peak at the innards of this _ iFly_Universal012207app.zip
Somewhere on lua.org is a list of products using it, astounding.
Did I see that 70% of Adobe Lightbox is coded in LUA? I think so.
I third a vote for Lua.
I think the combination of Lua and C is something that is better than C++ for making games. C gives you the flexibility to tie in with practically any OS and call OpenGL natively, as well as use libraries like libpng and OpenAL. It's also fast as heck. All of the logic in Psychonauts was done in Lua. Only the rendering/sound engine was done in C++.
I <3 Lua.
I have successfully replicated the basic functionality of Processing with C and Lua as of yesterday (setup, draw, keydown, stroke, fill, line, rect, beginShape, etc.). It's good stuff! I've got some great ideas with Lua that I think could work really well.
I think the combination of Lua and C is something that is better than C++ for making games. C gives you the flexibility to tie in with practically any OS and call OpenGL natively, as well as use libraries like libpng and OpenAL. It's also fast as heck. All of the logic in Psychonauts was done in Lua. Only the rendering/sound engine was done in C++.
I <3 Lua.
I have successfully replicated the basic functionality of Processing with C and Lua as of yesterday (setup, draw, keydown, stroke, fill, line, rect, beginShape, etc.). It's good stuff! I've got some great ideas with Lua that I think could work really well.
I have to say, I'm most happy with C and Lua. I had full lua support in my game inside of 4 hours. It's flexible, powerful, fast and easy to pick up. Give it a shot
It's worth the money
*
*it's free
It's worth the money
**it's free
djork Wrote:C gives you the flexibility to tie in with practically any OS and call OpenGL natively, as well as use libraries like libpng and OpenAL. It's also fast as heck.
C++ works with every OS that C does.
And I'm not sure what you mean by "natively". A C++ program can use OpenGL, OpenAL, or any other C library without any problems at all. There's no performance penalty for calling C functions from C++ programs. In fact, the resulting machine code is the same regardless of whether you're you're writing C or C++.
As far as speed goes, modern C++ compilers generate very efficient machine code, so there really isn't any difference in speed between C or C++. Granted, an object-oriented C++ program can be slow if it isn't well written, but I've seen many badly written C programs that are slow. It all comes down to knowing what you're doing; it has nothing to do with C versus C++.
GolfHacker Wrote:C++ works with every OS that C does.
And I'm not sure what you mean by "natively". A C++ program can use OpenGL, OpenAL, or any other C library without any problems at all. There's no performance penalty for calling C functions from C++ programs. In fact, the resulting machine code is the same regardless of whether you're you're writing C or C++.
As far as speed goes, modern C++ compilers generate very efficient machine code, so there really isn't any difference in speed between C or C++. Granted, an object-oriented C++ program can be slow if it isn't well written, but I've seen many badly written C programs that are slow. It all comes down to knowing what you're doing; it has nothing to do with C versus C++.
I wasn't saying that C was better than C++ for making games. I was saying that C with Lua scripting is better for making games than C++.
Trust me, I know the difference between C and C++, and I know what they share as well.
Thanks I guess it is just Lua as far as scripting goes. I'll check it out.
What is the ultimate answer to Life, the Universe, and Everything?
unknown Wrote:Im not sure why those two are trying to make you feel like youve asked a silly question, but take it from me you havent...
I'm surprised I missed this bit of your response earlier, but I take it `those two' includes me. I'm a little offended by your insinuation that I implied he was being silly. My `. . .' prefix was to denote that I wished to add at least a little more to OSC's curt response without going into exhaustive elaboration. Yeah, sometimes I restrain myself from blabbering believe it or not. However, if I were to blabber a bit more about it, I'd say Lua is my preferred language of choice as well.
Oops I didn't realize I was posting to Porting. I thought I was posting to Programming Languages. I'm very sorry.
What is the ultimate answer to Life, the Universe, and Everything?
Are you all happy with Lua as a language? I bought PIL a year or so ago and read through it ( and did some testing of my own ) and by the end I was thinking: "I wouldn't touch this language with a 10 foot clown pole".
Python & Ruby are beautiful languages. Lua may be practical, but it smells to me.
Python & Ruby are beautiful languages. Lua may be practical, but it smells to me.
I much prefer lua over python and ruby especially for this purpose, but overall as well. You might be confusing a language with the libraries it has, its important to make the distinction.
Sir, e^iπ + 1 = 0, hence God exists; reply!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Ruby for scripting my game engine... | djork | 13 | 7,861 |
Aug 20, 2006 06:48 PM Last Post: OneSadCookie |
|
| RGSS: Ruby Game Scripting System | Carlos Camacho | 5 | 7,882 |
Jul 31, 2005 06:26 PM Last Post: Carlos Camacho |
|

