Intergrating Scripting into a Project

Started by
9 comments, last by Whirlwind 23 years, 10 months ago
I''m not there yet, but I would like to add the ability to script actions, behaviors, and level events in a project, and haven''t a clue where to begin. I do have the idea that I have to design the project from the beginning to use scripting in a project, but I have no idea where to begin. I have an idea of using an existing scripting language, in this case perl - the source code is out there. It might help if I would take the time and mod a weapon or two in UT or Q2. I guess it is hard to understand something without a foundation of knowledge to start on. I guess I sort of came to a way to answer my own question, eh? I do think the actual intergration of a script with the project engine itself will be the tough part. "Check out my progress on the Ge Game engine at GeGames.com"
Advertisement
I''m guessing that creating something like a weapon in UnrealScript wouldn''t really help you understand how the scripting capability itself is implemented in the game''s code.

I know very little about doing this myself, but I have two suggestions for resources that might help. One is the Quake source code. Quake used a proprietary scripting language similar to C ("Quake C") for scripted behavior of enemies, etc. Also, I think the source code for Hexen has been released, hasn''t it? I know I''ve seen a gl version of Hexen so I''m sure the source is out there. Hexen used a scripting language to create sequences of events in the levels, but I don''t think it was used for enemy AI (I don''t remember much, it''s been so long).
I belive www.flipcode.com has a tutorial on implementing scripting..
Yeah, the source code for Hexen and Heretic is helpful and can be found at http://www2.ravensoft.com/source/.

-Ironblayde
Aeon Software
"Your superior intellect is no match for our puny weapons!"
Scripting languages can be very very simple and still get the job done.

I believe one of my first implementations of scripting wasn''t too far from assembly (had comments, easy to read functions, single line per executable statement, spaces between params, etc.)

It served the purpose just fine, although now I have a more powerful version.
___________________________Freeware development:ruinedsoft.com
Scripting is quite simple actually.

Develope a script parser which uses BNF (backnus naur form) to parse the script file and generate a cache. (Use a vector to store the cache)
Then create a Preprocessor to analyse the cache and generate a linear instruction set.. Such as break up IF and WHILE loops into simple goto''s

script objects using virtual base functions such as

virtual void ScriptObject(LPSTR lpszMethod,LPSTR lpszParam,LPVOID lpReturn);

you can also use RTTI and typeid to identify objects during runtime..

call objects using their base function such as this
((CControl*)GetlpObject("myplane"))
->ScriptObject("rotate","20",&Return);

My engine uses dynamic scripting which generates the language during runtime so that new objects are located during runtime


quote:Original post by jwalker

Scripting is quite simple actually.



Heh. If it was -that- easy, I think everyone would be doing it

quote:
Develope a script parser which uses BNF (backnus naur form) to parse the script file and generate a cache. (Use a vector to store the cache)


There are entire books dedicated to this.

quote:
Then create a Preprocessor to analyse the cache and generate a linear instruction set.. Such as break up IF and WHILE loops into simple goto''s


There are entire books dedicated to this also

Want to go into more detail?
Anyone know of a (perferrably free) version of Lex/Yacc for Win32''s?

C=64
>> Anyone know of a (perferrably free) version of Lex/Yacc for Win32's? <<

Bison is a Yacc clone for Win32 and Flex is a Lex clone for Win32. Go to this page to download them from a server near you

/. Muzzafarath
Mad House Software

Edited by - Muzzafarath on June 13, 2000 9:15:26 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
I forgot about quake and quake C, and yes, the Hexen source is out there too. I''ll definitely need to check out flipcode.com more.

Doesn''t Quake 1 use yacc as a parser for Quake C?

jwalker:

Wouldn''t be easier to intergrate the perl parser into a program and write hook modules to interface with your program? I could just write the whole thing as a perl module. Use perl to set up everything, and pass the data to the actual program - which would be a perl module.

It doens''t necessarily need to be perl, it could just as well be any freely available scripting language.

Eventually, I''ll get around to being on a level to write a from scratch scripting language, but for now the more out of the box, the better.

This topic is closed to new replies.

Advertisement