🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

why a scripting engine??

Started by
12 comments, last by Spencer 23 years, 2 months ago
Hi! I am a new gameprogrammer and i am currently writing my own 2d-iso.-engine. Now, i have read some articles about scripting- engines and languages. My question now is: why should i have one of those? Is it for my own good? is it for if others use my 2d engine? is it for my own showing-off-in-writing-a-compiler?? please enlighten me!! --Spencer
--Spencer"All in accordance with the prophecy..."
Advertisement
I''ve never actually implemented such a thing, so my answers are all in theory . One of the more obvious reasons is that it makes it easy for people to write mods. Another reason would be so you can work on character AI or scripted cinematic sequences (or whatever you want to script) without recompiling the game, or without even exiting the game if you can load and run scripts from an in-game console or something. I can see how a scripting engine might also help enforce well organized and modular code, at least in the area of objects and characters (and maybe special effects or whatever else the scripts can manipulate).
The reason for having a scripting engine? Simple.

A good engine is supposed to seperate logic and data. If you were to hardcode the interaction sequences, monster data, and other things, it would be hard to get the engine code to act differently if you were to make a sequel or an entirely different game.

If you use scripts, you can just edit the scripts to get monsters to act differently. Sound good?

- DarkMage139 (Neokatana Software)

GDT Underground Info
Release Date: "When hell freezes over" (a.k.a. A very long time from now)
Genre: Action/Adventure
Platform: Windows 98 and DirectX 8
Status: [working on the engine]
l337ness: TOTALLY l337



- DarkMage139
Game content development time can be significantly reduced with a scripted interface to your game engine. Where common engine tasks are automated, and depending on the power of your scripting engine anything that the game engine is capable of can be described and implemented in a simple script, which (presumably) is smaller and faster to write in than the much lower level language your engines are written in. Since it's instruction set is reduced to operations within the game that HAVE been hard coded and tested previously to writing the script, the chance for error is greatly reduced.

People who are incapable of writing the complex code of the inner workings of your game could more easily write content through the use of scripts. They are also very useful in making quick changes or total overhauls of sequences within the game, computer AI, you name it. In the end your code is less bloated, less prone to error, and FAR more extensible than hard-coding everything into the game.

In the end it depends entirely on the size and scope of your project. If you're making something very simple, then implementing a full-blown scripting interface is probably more trouble than you want to deal with, especially if you're programming in C++.

To script or not to script...

____________________________________________________

"Two wrongs do not make a right; it usually takes 3 or more."



Edited by - Ratheous on April 2, 2001 4:06:42 PM

____________________________________________________
"Two wrongs do not make a right; it usually takes 3 or more."
Some mistakes are too much fun to only make once.
Never anger a dragon, for you are crunchy and you go well with brie.

This was a hard and painful lesson I learned while writing my first professional title, I cannot stress this enough..

I try to put everything I can into scripts or config files..after you finish the game, there''s always going to be someone in design that says "Hey, can''t you make that grenade go a little faster?", or "can you make the player die after 6 shots instead of 5?", or even better, "Can''t the enemies sidestep between shots?"(new animations, new code, etc.)..(BTW these are REAL examples, and man, was I pissed..at myself)..

After rewriting and reworking code that should have been complete when I did it the way the design team asked for it the FIRST time, I realized that I was spending more time tweaking small things like this than doing my job, programming..

I put the project on hold for a whole month to develop an AI script and seperate the data from the code..after that, when I got hit with a last minute design change, I could do it in minutes instead of hours, AND in most cases I could tell the designers where things were and let THEM tweak the details to their hearts'' content..

Trust me..if even if you don''t think you need it, put EVERYTHING YOU CAN in some external script or textfile..even if you don''t write a full blown script compiler(a FUN and challenging experience), keep your game-specific data as far away from the actual game code as possible..



"Like all good things, it starts with a monkey.."
"Like all good things, it starts with a monkey.."
The simplest answer is that scripting allows you to change behavior without recompiling. Scripting allows clients to change program behavior or create new behaviors (i.e. new levels) without needing access to the source code of your program or a setup to build it from scratch.
i guess this is probably a dumb question, but how long does it take to recompile an entire game? i dont know because ive only worked on small things. is it really that long? i know it depends on the game, but say a new 3d shooter or something like that.

plus, how does the actuall engine and the script files interact? do you run the engine, and then it automatically opens the script? you say its easy for changing different types of ai and stuff, but doesnt the different types of ai that the scripts have to choose from depend on the types that you have hard coded into the engine? isnt that a lot of extra work?
I have never *successfully* implemented a scripting engine, but I think I can answer that question... or at least the script/engine interaction part. I would guess (at least this is how I tried to do it) that the engine keeps a big database around with all the script files in it. It knows what scripts go with what other stuff because of the database. Then, if you want to load an AI into a creature, it reads something like "if bullets is coming at my head, move left" as opposed to "execute AI behavior 1" which seems to be what you were thinking A good script could completely influence the behavior of a bot.

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

www.verge-rpg.com is a good game engine that uses scripts, and is open source, so you can see how it''s done.
I''m not planning on using scripts in my engine though, cause it seems like I could just make the engine files, and then just put another folder in my project for the data files, and just call functions in C++ like I would scripts...
And to solve MonkeyMan''s problems, why not just use variables for the max hits, grenade speed, etc? Seems like you''d have just as much trouble changing it in a script as you would in C++... Or maybe I''m just ignorant, as I''m still only working on engine code for my game. Not sure about sidestepping though, but it does seem like you''d just change the enemy AI functions the same as you would with a script.
From what I''ve seen, scripts just make it take a little less text to do things, and I''d probably spend a lot more time coding the script compiler/engine than I would just hard-coding it. Plus, it''d probably be a little faster too^^


-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)
quote: Original post by DekuTree64

And to solve MonkeyMan''s problems, why not just use variables for the max hits, grenade speed, etc? Seems like you''d have just as much trouble changing it in a script as you would in C++...


I am using variables, of course; I load them from the text file at startup and go from there..

I guess I strayed from the topic a bit(sorry), in addition to runtime scripts I was also talking about config files..

The situation I was referring to is when you''ve already written the code, everything''s solid, and the designers have to personally bug you to tweak some small thing("can''t you make that just a bit faster?"..recompile..redeliver.."now it''s too fast..can you slow it down just a hair?"..recompile..redeliver..

I got sick of it and started putting ALL parameters great and small in some text file so I could tell them to change it themselves; I have more important things to do than to tweak acceleration, viewheight, etc.

There are SO many things you can adjust in a game, from max damage hits to kill range for landmines, etc...you get the idea

Here''s another example:..let''s say you compiled your game, you''re showing it off on your friend''s system, and you want to change 1 small thing..you can''t drop everything and recompile if the system has no compiler..

If any variable that affects gameplay can be tweaked, it should be external to the code..it''s a hard habit to get into, but once you do you''ll never go back I promise

I cannot begin to estimate the time this has saved me..it''s not as mind-bending as writing an engine that uses runtime scripts(which I won''t even go into right now), but the benefits are immediate..just think, when was the last time you recompiled your project just because you wanted to tweak some small variable?..I know I''ve done it many times and in the long run it''s easier to dump it into a text file and load it at startup..

But the greatest part is, it keeps designer/artist/QA/non-programming people from bothering me


"Like all good things, it starts with a monkey.."
"Like all good things, it starts with a monkey.."

This topic is closed to new replies.

Advertisement