Jump to content
  • Advertisement
Sign in to follow this  
Drunken_Monkey

Why you would want to call scripts...

This topic is 4216 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

I recently learned on how to make Python calls from C++. I think it's really, really cool that you can do that, but when would you ever want to? The only scenario I can think of you would ever want to call Python from C++ is when it's just plain easier to write scripting code rather than writing lower level code, but isn't that the case with all scripting languages? Can someone enlighten me of when you would ever want to call Python from C++ besides that it's just plain easier to write Python code.

Share this post


Link to post
Share on other sites
Advertisement
By using scripts to drive your engine, you don't have to recompile your whole application in case you want to modify some of it's behaviors later on.

As an additional benefit, if you expose the scripting interfaces to the end users, they can make mods for your application. If you have a good game engine, for example, this may be a strong selling point.

Share this post


Link to post
Share on other sites
First, it's usually easier to concentrate on game details in a high-level programming language, and it's more expressive as well. But that's the "it's easier" argument.

Second, you don't need to recompile the game when you want to alter something. You can run the game in full optimization mode and change scripts on the run in the course of a few seconds, as opposed to the half-hour-plus compile and link times on large projects. Sometimes, some virtual machines even allow you to pause the game, tweak a few values, call one or two python functions manually, and resume with the new state.

Third, it's difficult to get something wrong done in the sandboxed environment of a script. So, you can allow people to write scripts and distribute them very easily (even let the game download them automatically) without putting the user's computer's safety at risk.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drunken_Monkey
Can someone enlighten me of when you would ever want to call Python from C++ besides that it's just plain easier to write Python code.


Don't you think that's a great reason all on its own? If you can make coding a game twice as quick or easy, then why not do it?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!