Jump to content
  • Advertisement
Sign in to follow this  
Kain5056

External functions?

This topic is 1930 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 have a newbie question about C++.

My program can read variables, strings and stuff from an external file with no problem.

But is there a way to make my program read whole functions, or at least if statements from an external file?

 

Like, having a .txt file with "if( something > something else) something = 0" written in it and my program being able to read it from the file and execute it in some way?

 

Thank you in advance. :-)

Share this post


Link to post
Share on other sites
Advertisement

Sure, plug in a scripting language runtime, or package it with a compiler, and you could get this kind of functionality.

 

Examples of some scripting languages that are fairly simple to hook up include lua and python.

 

You could also write a basic parser/lexer and plug it into LLVM to JIT compile code on the fly.

Edited by Washu

Share this post


Link to post
Share on other sites

As the previous poster already stated, you're looking for an embedded scripting language. To use it you need to bind portions of your game to the scripting engine. To get started, take a look at these two scripting languages:

The latter has its own subforum here on gamedev and it's fairly easy to bind C(++) functions to it.

 

I don't recommend you to write your own parser/lexer, as you need quite some knowledge to do that and it seems you're a beginner.

Share this post


Link to post
Share on other sites

Thank you both for the help. I will look into your suggestions some more and then I will decide what method is best for my needs. smile.png

Thank you again. smile.png

Edited by Kain5056

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!