Sign in to follow this  
polarboy

[Solved]Embedding C++ with scripts

Recommended Posts

polarboy    145
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]

Share this post


Link to post
Share on other sites
polarboy    145
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?

Share this post


Link to post
Share on other sites
Sneftel    1788
I think he was suggesting that you TELL us which scripting language you're referring to.

Share this post


Link to post
Share on other sites
Mike2343    1202
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.

Share this post


Link to post
Share on other sites
polarboy    145
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

Share this post


Link to post
Share on other sites
swiftcoder    18432
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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this