Sign in to follow this  
efegea

Problem understanding scripting

Recommended Posts

I know what scripting is and what is for. But there's still something I don't get. I want to use scripting because I don't know how to code in c++ things like non-interactive scenes, and because I want to desing the levels this way (my game is some kind of 2.5D (as in castlevania rondo of blood psp remake) survival horror (the main character is a "paper doll" with Flashback or the original Prince of Persia-like movements) It's a bit weird, but well.. I'd prefer to use c++ because I'm coding for a GP2X, which is only 200Mhz and I'm already using a 3D software renderer, so it has not power to run any scripting language, I think.. Can someone explain to me how it's done in c++ without using a scripting language? if not, how it is done using an scripting language as lua? I don't get how it's structured, if it's better to use one big script or multiple little scripts, and if the last, how it's done on multiple scripts.. I've read Game Scripting Mastery, but there is still something I don't get.. :(

Share this post


Link to post
Share on other sites
Scripting isn't going to magically make this any easier. If you can't picture it in C++, you probably won't be able to do it in Python or Lua either. What you're really asking for therefore is not really anything to do with scripting languages as such. I suppose it's more a question on how to implement 'scripted sequences' and cutscenes?

Share this post


Link to post
Share on other sites
I've always thought that is more easy to implement it using scripting languages than in c++, but perhaps I got the wrong idea

Share this post


Link to post
Share on other sites
It seems that you're confusing two seperate things; scripting languages and a "scripted" sequence of events.

A scripting languages is much like a programming language like C++/Visual Basic/Java/COBOL/etc in that it is for the processing of logic.

A "scripted" sequence of events is different in that it is about a predetermined sequence of things that happen, for example; Object _A_ travelling between a series of points in space and orientations over a period of time.

This could be implemented using a scripting language, and many of these are done in scripting languages, but they are not dependent on being implemented in a scripting language they could just as easily for the above example be a series of positions and orientations defined in an xml file that is read in a C++ program.

For example; I wrote a C++ based system that read in the "scripted" animations of a group of cubes and spheres at college. This was just a list of positions, orientations and the time at which they had to happen. The C++ code then just interpolated between them all during execution. Obviously thats a hideously trivial example but it should make the point that it doesn't matter whether you're interpolating between the positions of a cube, or the frames of animation for a 3d model of a diplodocus!

I hope that clarifies things. Sorry If it just confuses them more!

Andy

Share this post


Link to post
Share on other sites
For simple scripting you could use C/C++ macros and have the benefits of the compilers abilities to do math etc...

Same you could just use high level function calls in c/c++ .

You would have to pass the 'script' thru a compiler and reexecute the program (or do something tricky with a DLL which could be released recompiled and reacquired without stopping the main program...)


script examples


buildingx = AddBuilding(buildingtype, x, y);

unitx = PlaceUnitNearBuilding(unittype, buildingx, radius);

EquiptUnit(unitx, itemtype);




Ive been looking at similar 'scripting' methods as a scenario builder which given a number of primary elements and a selection of optional flavorings, and some very clever use of random and relative placement functions and well designed building blocks, can produce semi-randomized scenes which could overcome that repetative 'always looks the same map' problem that so many games exhibit.





Share this post


Link to post
Share on other sites
Possibly the most compelling arguments for scripting languages in games are:
- you dont have to be a programmer to use one
- you dont have to recompile to tweak one

The difference between something like python and c/c++ or java is that a programming language has a lot of constraints which you have to be quite clever to work within. Most people would find them annoying, confusing and cumbersome. Of course to a computer programmer it is interesting, challenging and a lot easier than assembly ;-) The point is that scripting languages provide an interface for people outside of our domain to put simple bits of code together without all the same constraints. A scripting language often has the capability to perform simple functions, but we still write the functions the script will use to do something in the game. Load a character, play a sound, make the character walk onto a podium, then make him punch the air and make firework particles explode in the background .. All of these things could be functions in C++ and then chained together into a logical sequence in a script.

The fact that you dont have to recompile is also important. If you set up a test properly then you dont even need to reboot to tweak a script and rerun it, but the main thing is that a designer can make a scripted sequence.

So you see, scripts help to make your program data driven, and the main reasons for wanting them in the first place is to enable other users to put sequences together. This isn't the only reason of course, there are several benefits to scripting. The best way to think of a script is as an intelligent data store which can execute logic.

Hope this helps, and good luck!

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