Sign in to follow this  

Why should i use a scripting language???

This topic is 4337 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
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
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
Quote:
Original post by Xai
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.

If you as I suggested just used Lua tables to store data, it would be no problem to write a tool for editing them even though I would consider it unnecessary given the simple nature of their syntax. It's just a comma separated list of key/value-pairs. You don't need to be a programmer to do that except for writing function values which no tool can do for you anyway.

And why would you need to parse it to get information from it? Just write a Lua function to iterate through the tables and gather the information you need.
Lua was originally intended to be used for data description and configuration.

Share this post


Link to post
Share on other sites
Quote:
Original post by Xai
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.

Well, Lua. Isn't that kind of the point?

Share this post


Link to post
Share on other sites
Quote:
Original post by Xai
i double dare you to crank out an Animation File Editor tool that edits your LUA script data - in a similar amount of time.

On this one: Why not write the editor in Lua, operating on Lua tables. Something as complex as this can be used to stream it to disk: http://www.lua.org/manual/2.1/subsection3_7_3.html

Share this post


Link to post
Share on other sites
I was just reading this thread, and it seems that using scripting languages for AI would be usefull for me. I was wondering where can I get more info, and maby library's for processing scripting languages, thats free.

Do any of you use a library created by someone else (Outside your programming team) for enterpreting scripting languages for AI or whatever needed, or did you (self or with programming team) make the code to interpret it yourself.

Thank you!

Share this post


Link to post
Share on other sites
My own experince so far is to hardcode AI logic and stats and whatnot into game characters.
But this scripting concept sounds interesting.
Would someone like to try and convert me to the church of scripting?
Intro to paradigm, learning resources, etc
Thanks

Share this post


Link to post
Share on other sites
I think the idea wouldn't be to code AI in a scripting language, rather code the AI inside your engine and use scripting to control the AI. For example, the AI might have different attitudes that any NPC can have. Your resources (script and XML data) could control which attitude is applied under what circumstances for a specific character.

Or another example, suppose you have an AI that does pathfinding. The AI has parameters that control how hard it tries to find a path. Maybe you want one type of character that's better at it than another. Each of the character types can be defined in script and have these values to pass to the AI.

If you've got an AI that understands goals, you could use data files to describe constraints on the goals. This is kind of complicated, but I read a lot on it recently and blogged what I learned. You can have a look at tools like Graphplan for examples of this kind of resource (Graphplan is old, but I found a lot of info on it and understood it).

As for external libraries, there's Mozilla Spidermonkey for javascript and Lua as mentioned earlier. For XML the classic library is Expat. (check the license before commiting on all these of course)

Share this post


Link to post
Share on other sites

This topic is 4337 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this