Skip to main content
GameDev.net gamedev.net
🔒 Locked

using scripts...!!!

Started by yodaman Apr 24, 2003 at 11:21 PM 9 replies 700+ views
Original Post
yodaman
yodaman
Told you all I would have a new post soon Anyway, Ive been recently thinking about using scripted AI, fx, and such, but I have no idea how to go about using scripts. I would imagine that doing a if else check for 5000 different script codes would get pretty messy, and I wouldnt have the firt clue about hopw to make a "script compiler". I would just mainly like to use scripts for particle fx, event triggoring and AI. if any one can tell me a good sight that covers scripting... I love you! j/k lol. thanx alot guys and gals! ~yodaman
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org
snisarenko
snisarenko
I''ve written a small script interpreter once in my AP Computer Science class. Believe me it was not fun... but I miraculosly go it to work

Writing your own scripting interperter (especialy the one that understands a complex script is not easy). But u probably already know that ..

so I googled and I found this: http://www.geocities.com/SiliconValley/Hub/5282/eng/file4.htm#L3_Antes

Hope this helps
llvllatrix
llvllatrix
It all depends what you are using it for...im guessing demo. If you''re doin a game then you need scripts. No way around it. But if you are doing a demo then you can code all your scrips and things should be fine if you keep everything neat.

Heres how i go about it:

I make a basic abstract scene class with a beginning and end member and play, update, and initialize functions and in my main loop write code to call an array of pointers to the abstract scene class.

I also make base classes for standard effects - like particle and the such.

Now for each scene i want to make, i inherit from the base class and whenever i want that scene in my demo i make a pointer in the array point to an instance of this class - polymorphism.

Lets say i want a particle emitter to act a certain way in one of my scenes. I write a class that inherits from the standard effect, and write a think function for it. Make sure to define the class in your scene class though - that way it can only be used in that one scene so you dont get messed up.

Thats about it...so far. The reason i use an array of pointers is so that the main loop is only concerned with the current time frame so you dont have to check for all scenes at once and you can easily expand the length of your demo without major changes...just change pointers.
jonbell
jonbell
Buy "Game Scripting Mastery" its a good book (although fairly long winded). It tells you all you need to know.
yodaman
yodaman
well, the thing is, im developing a small level editor as well,
and I wanted to have drop and paste script codes, that are of course tweakable. llvllatrix, has a good method it seems, hmm,
I wanted to use a language like python though for it, what do modern games use, there own script language or something like perl, python, etc?

Thanx

[edited by - yodaman on April 25, 2003 3:15:16 PM]
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org
snisarenko
snisarenko
Unreal uses its own script.

I am not sure but I think half-life also uses its own script.
sean_r
sean_r
Some people use Lua. I''ve never used it, so I can''t really say if its interpreter is easy to embed into your program or not.

Python is embeddable, and doing it is fairly straightforward. The documentation for extending and embedding the Python interpreter is pretty good and fairly complete IMO.

Tcl is also fairly straightforward to embed, but the documentation on how to do it isn''t as good as for Python, IIRC.
sean_r
sean_r
One other thing:

If your program is interpreting the raw text for each frame (or even every 10 frames), yeah, it''s going to be REALLY slow.

The key is to compile it to bytecode (which you make up if you''re writing your own interpreter from scratch, and that''s how Python, Perl, etc. do it AFAIK) when the program first starts (or when the level is loading, or whenever; basically any time prior to the actual gameplay), and then interpret that, which will be as simple as a bunch of case statements.

If you REALLY REALLY REALLY want to write your own scripting language, and would like to see an example of a compiled-to-bytecode-and-then-interpreted language, have a look at a CinePaint plug-in that I wrote called IOL (Image Operation Language). The language itself doesn''t apply to games, but the underlying concepts do.
fractoid
fractoid
You could also check out the gamedev.net article seriers on "Creating a Scripting System in C++" - I had a brief glance through and they seem to be fairly comprehensive.

Parts I to V:

http://www.gamedev.net/reference/articles/article1633.asp
http://www.gamedev.net/reference/articles/article1686.asp
http://www.gamedev.net/reference/articles/article1788.asp
http://www.gamedev.net/reference/articles/article1803.asp
http://www.gamedev.net/reference/articles/article1877.asp

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.