[Solved]Embedding C++ with scripts

Started by
6 comments, last by polarboy 14 years, 10 months ago
Hi, just started reading on embedding scripting languages within C/C++. There is something I am not getting. I have read that you can call a scripted function in C++ as well as calling a C++ function in the scripting language, but what about the variables? How do I access a variable in C++ in my script? Is it possible? Also, how does the return work? Say I want my script to return the result in a class called list, would it be able to do that? Thanks in advance Edit: Okay, I get it, In lua, I can use the stack and etc. I will revisit the stack section in the tutorial Thank you [Edited by - polarboy on June 17, 2009 8:45:22 PM]
Advertisement
The answers depend on which scripting language you use.
Thanks for the quick reply, wasn't expecting such a quick one,haha

I have just read something called variable linking
but they are only used for certain types (ie int, char)

So I'm guessing it's best to avoid this? So I would probably just set up everything in my scripts and just call c++ functions (ie. render) while providing them with all the necessary parameters?
I think he was suggesting that you TELL us which scripting language you're referring to.
There are dozens and dozens of scripting languages out there, until you tell us the one your considering or looking at, we have no clue. Each one basically does it their own way.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

Ah, okay, I don't know which one I'm gonna use yet, I'm just reading about them atm.

I'm looking at some tutorials for Lua, Python, GameMonkey and possibly PHP right now

I guess I'm really asking if this was possible to do rather than how to do it
Quote:Original post by polarboy
I'm looking at some tutorials for Lua, Python, GameMonkey and possibly PHP right now
I would suggest you go with a scripting language which has been widely used in games - both Lua and GameMonkey are decent choices.

PHP on the other hand, isn't widely used as a scripting language for games - it would work, but it is more oriented to web development, and there aren't as many resources on embedding. Python is also a bit large and unwieldy for game scripting use, and can be a bit of a pain to embed (even with tools such as boost::python).

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

cool, thank you for your suggestion

This topic is closed to new replies.

Advertisement