Sign in to follow this  

Scripting for C++

This topic is 3113 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, I have made a particle system and I want to implement some kinda scripting system so I don't have to re-compile everytime I want to change a little constant or some particle behaviour. I have heard you can get some scripting for C++ (An example would be how World of Warcraft is using LUA). So I was thinking if anyone know of some way to do this. I'd rather not code it myself, cause I'd like it to be some known language like Ruby, Python or LUA. If anyone knows anything, please link or tell me about it. Thanks in advance.

Share this post


Link to post
Share on other sites
I prefer Lua as a scripting language. It can be a little tough to bind to C++, but there are helper libraries out there.

If you want to start simple, then you could also load a plain text file with one line per variable and use that to tweak your particle system.

Either way that you go, you're going to need to write some code. I think that with a simple text definition file for your particle system, you can get away with less code than binding Lua (or some other scripting language) to your particle engine.

Cheers,

Bob

Share this post


Link to post
Share on other sites
I thing embedding a scripting lanquage is the easiest solution. I've tried Python myself (not without problems) and it took me about 2 days (about 4 hours not 48 [smile]) of reading the manual and trying (I use c++). To change a variable (possibly a particle behaviour) I use about 50-60 lines. I think using a scripting language is the least coding and the most bug save approche.

which scripting language to use is up to you, I suggest look at them all (and how to embedd them, which looks the easiest).

The approche of Scourage (load a plain text file) is a nice solution too. It saves you learning a scripting language (although changing some variables isn't that hard) and learning to embedd it but it gives you the new problem that you need to make your own "script"-loader.

say your a "script" looks like:
<life> = 5
<speed> = 6
etc.

the loader would look like.
look for "<"
see what for token is after it (if invalid: error)
look for "> = " (if not there: error)
look for value and assign it to the corresponding variable.

Link you might use (some might be obvious [smile]):
Python
embedding python
lua
ruby

by the way if you use a scripting language I think it's easier to make one function to change particle behaviour with a enum (id, integer) as argument which property to change because making more function acsessable for the scripting language is much more work than make a id for every propery.

example:
instead of:
ChangeLife(float), ChangeSpeed(float)

ChangePropery(int propery, float value)
{
swith (propery)
case Life:
Life = value
case etc. etc.
}

but this is how I would do it and maby there are beter alternatives.

Share this post


Link to post
Share on other sites

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