Examples of the benefits of using scripting languages

Started by
38 comments, last by Kylotan 21 years ago
I know that the accepted wisdom is that using a scripting language makes your development go a lot more quickly. But I can''t really think of many examples right now, and therefore am loathe to begin on the path of integrating Python or Lua with my existing projects unless I can clearly see the benefits. I find Python a little simpler to use than C++, but not so much so that it would save me a lot of time, especially once integration time was taken into account. But I''m willing to be proven wrong, so can anyone with experience of this post an example or two of how it has helped them? [ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
Advertisement
What if you had 6 montsers, you wanted one to come straight at you, one to circle behind you, one to stand his ground and wait for you, another to try snipering you, etc, etc. If you have a scripting engine, you can have them do this without modifying code, which means, your artists/level designers don''t need to have a hold of your code, other people can produce enemies for you, without needing code, etc. Also, what if you wanted to add a new weapon? You might want to use a script to define how the gun works, or a script that could handle what sound effects happen at what points on a board, etc. Of course this can all be hard-coded in, but then it''s just not as flexible for end users or your own level designers to play with.
Scripting makes things faster because you don''t have to recompile after every change. Large projects can start taking a LONG(hours) time to compile, and if you have all the logic scripting it only takes 30 seconds to make a change and see how it works instead of the time to compile and link.

Another benefit is that it allows 3rd parties to make modifications to your game which is becoming more and more popular with FPS. Some very high-quality mods have come out for most of them, which continued their success for a long while.

Also, as Ready4Dis said, it allows more customization in level files, so you don''t have to hard-code each level. If you want something to happen in a map, you open up the script editor and type in a few lines and it''s done. No need to open up the full source for the engine and make a new function Level_205228() to handle the custom stuff for that section.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Ok, I should have made this clear, but forget 3rd parties (including in-house 3rd parties such as artists and designers) as they aren''t part of this particular equation. I''m thinking purely in terms of development speed.

My largest project to date takes 5 minutes to do a full recompile. This is not insignificant, but then I rarely need to do a full rebuild because I''m not too bad at managing my dependencies. So it could help here, but since I rarely spend more than 2 minutes on any given compile, and would spend at least several hours integrating a scripting language, I believe it would be a long time before this single aspect would benefit me.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
I was going to use Python as a scripting language for my online game.. But then I realized that while the client wouldn''t have to run the slow Python much (most processing time goes to drawing), the server would then use Python almost solely. Meaning it could run maybe 1/5 or 1/10 the amount of players it could if it was pure C++ (assuming bandwidth isn''t limiting factor).

Now I''m not sure what to do: (1) Not use scripting at all, (2) try Python anyway and settle for it''s speed or (3) maybe write my own simplified scripting language that''s faster to interpret and more tailored for my needs. But considering I don''t have experience with the last one, it could (likely) end up being slower to interpret than Python...
It totally depends on your project. A scripting engine to do the cut scenes in pacman is a huge overkill; you''re going to go crazy without some form of scripting language to do an rpg. I know you want specific information, maybe if you posted a bit about your project or what you''re trying to do we could help a little better.

regards,
Ratman
Scripting would benefit all applications except the smallest ones IMO. Say you have a simple text editor. But if anyone can write simple extra tools for it with Python, it''ll suddenly become incredibly flexible. Someone else could incorporate spell checking or, say, a regular expression search.

In games, well just look at Counterstrike and other successful mods based on Quake''s scripting capabilities.

Scripts may not allow you to work amazingly much faster, but they enable other people to safely extend your application without having access to source code. Or you could easily download new scripts from the net and start running them right away.
I am just talking generally. Some people claim that they can develop their game a lot more quickly using Python (eg. "I have felt so liberated by the speed with which I can make changes and see the effects, the speed with which I can put my ideas into practice and the flexibility of the code"), so I''d like to see some examples, more specifically to do with code than game design (ie. cutscenes, scripted behaviour). I''m not asking for help with my specific problem or project of my own, just some ideas of how it''s benefitting other people.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
I would only use scripting if other people needed to add behavior to monsters without compiling or if I were thinking of making new levels for download containing new behavior without changing the exe file.

I don't think the development time is the reason for the use of scripting. Flexibility is the reason I think.

But what the Hell do I know ?

Let's here it from somebody who knows what they are talking about

[edited by - granat on March 16, 2003 12:27:14 PM]
-------------Ban KalvinB !
Okay, I think I see what you are looking for...concrete examples. I don't know how "right" my approach is, but maybe showing you a bit could help. In my 2D sidescroller almost all of my game classes are exposed to Lua with a slick automatic binding tool called ToLua. So then its possible to do things like this--say I want to have a new monster spawn when one monster is killed. Here's a snip of Lua code that defines what is executed when the monster dies:
--OnDeath Function-------------------thisMonster.OnDeath =  function()    newMonster = Monster:new(thisMonster.X+20,thisMonster.Y)       newMonster.AI = AICollection.lizard2    newMonster.Sprite = SpriteCollection.lizardred    game.state.scene:AddObj(newMonster,true,true)  end------------------------------------- 

Basically I think whatever effort is put into implementing the scripting system more than pays off in the end; things are just easier to customize, and creating interesting events just kind of comes out of the functionality of the system. In a Pac-Man game, yeah--its overkill (probably but for the kind of interactivity that I want in my Metroid-style game going for Lua was a good choice, I think. Also remember you can implement a console in your game and make changes on the fly as the executable is running!

[edited by - thehurricane on March 16, 2003 12:28:51 PM]

This topic is closed to new replies.

Advertisement