Jump to content
  • Advertisement
Sign in to follow this  
ehsan_the_tiamat

Why should i use a scripting language???

This topic is 4680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

HI I'm developing a game and i need to know why should I use a scripting language? i've seen people talk about them a lot so they're very popular but I dont know what they do in graphics engines. by the way, for an indie 3d game which one should i use: XML or LUA??? THX in advance

Share this post


Link to post
Share on other sites
Advertisement
Scripting languages allow you to modify your game more dynamically. Information that is determined through scripting can be modified without re-compiling the game, which saves large amounts of time on large games, and also allows third party users to modify the game within reasonable limits.

As for your question XML versus LUA: you don't need to choose. XML and LUA do different things: the former structures information while the second describes actions. Storing information as XML allows you to read and modify that information with ease. Using LUA to describe game actions allows you to modify these actions outside or even inside the game, as well as interact with the game using a scripting console.

Share this post


Link to post
Share on other sites
Quote:
Original post by ToohrVyk
Scripting languages allow you to modify your game more dynamically. Information that is determined through scripting can be modified without re-compiling the game, which saves large amounts of time on large games, and also allows third party users to modify the game within reasonable limits.

As for your question XML versus LUA: you don't need to choose. XML and LUA do different things: the former structures information while the second describes actions. Storing information as XML allows you to read and modify that information with ease. Using LUA to describe game actions allows you to modify these actions outside or even inside the game, as well as interact with the game using a scripting console.


In addition to this, there are some games that even use both XML and LUA together, World of Warcraft for an example.

Share this post


Link to post
Share on other sites
As to why you should use scripting consider this: If you wanted to you could write an program that converts your data files to header files (i.e. store all the data in predefined constant arrays) and then just include all the header files instead of writing stuff that loads your data from files. Needless to say this is a bad idea, so why do the same for your game logic?

Share this post


Link to post
Share on other sites
Here's why I'm using Lua: I don't want to create a separate class for every single enemy type in my game. There's going to be a lot of them, and the messiness involved in all those extra classes would get really ugly really quickly. By using scripting, I can just have a single generic "enemy" class that draws its AI from the Lua scripts. Much cleaner, and the ability to tweak the AI without having to recompile is very nice.

Share this post


Link to post
Share on other sites
I think Monder really nailed it. Scripting makes it possible to extend and rearrange your game without rebuilding it. It can move a lot of things from build time decisions to run time decisions.

Share this post


Link to post
Share on other sites
Why use XML *and* Lua when you can just use Lua?

Lua is excellent for describing data, and you can mix code with data! Lua is fast so I wouldn't worry about the performance of using Lua to store data. Also, XML is ugly.


monster = {
hitpoints = 20,
anim = {
idle = "idle.png",
walking = "walking.png"
},
onActivate = function(self, who)
face(self, who)
say(self, "Hello there")
end
}




[Edited by - robinei on January 27, 2006 9:37:25 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by robinei
Why use XML *and* Lua when you can just use Lua?

Lua is excellent for describing data, and you can mix code with data! Lua is fast so I wouldn't worry about the performance of using Lua to store data. Also, XML is ugly.

*** Source Snippet Removed ***


It definitely makes sense to describe data in Lua internally if you're already using it. XML can be useful when you need to share data with other applications. One example would be uploading statistics to a web site.

Share this post


Link to post
Share on other sites
I don't know LUA, but XML is made for storing or transfering data, programming languages (and scripting languages) are made for doing things with data. Generally XML would be better for cases where you want to be able to do things to resources outside of the game. I could use another tool to easily load up an XML file and operate on it (maybe I want to see the prices of a bunch of items and adjust those numbers). I could make that work for a script, but it's easier with XML.

Of course there are other good approaches depending on your needs. I'm sure you could use a CSV file which could be copied & pasted into a script for some of the same kinds of processing I described above.

Conversely, there's always javascript and E4X for embedding scripts in your data.

"You got your data in my script!"
"No, you got your script in my data!"
(too obscure?)

Share this post


Link to post
Share on other sites
I can't imagine keeping my DATA inside my LUA / ruby scripts ... or my C++ program, or any of that. The reason, because what the hell tools out their know how to parse LUA correctly to present the lists of data to a non-scripter so they can edit them? What tools out their exist to parse these lists and generate lists of the resource files currently used in your project.

NONE!

Plain Old Text
CSV
XML
SQL

These are THE formats to use for your pure data sets.

First, because you can convert between them relatively easily, import them into other programs, and EASILY write editor programs ...

i double dare you to crank out an Animation File Editor tool that edits your LUA script data - in a similar amount of time.


AS for the "why use a scripting language" question. Well the main reasons are:

1) The non-compiled nature often makes it slightly easier to perform small quick changes and see results. Although these benifits are usually overrated because people simply lack the knowledge of how to do this well with compiled code (dynamic plugins).

2) The smaller / simpler nature of the languages often make them easier to teach to non-professional programmers such as level/model designers. So they can be writting the detail logic, in a small sweet langauge using the tools provided to them by the engine programmer.

3) The non-compiled nature of the langauge allows code to build code dynamically. For instance a script written could enter "DoMegaDamage(true)" as the data for a certain action for a certain object. And this could call the exposed wrapper function "DoMegaDamage(true)" In C++ you would have to write a lot of scafolding / building maps and parsing to get a simlar ability.

There are more ... but I'm out of steam

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!