Sign in to follow this  

[Solved]Embedding C++ with scripts

This topic is 3099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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
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

This topic is 3099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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