|
|
|
View previous topic - View next topic |
Author |
Message |
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Thu Aug 07, 2008 3:52 am Post subject: Self-made scripting vs. lua, javascript, etc. |
[quote] |
|
I've been debating whether to use a scripting language like lua for my rpg, or to use my own custom made scripting system.
Using my own scripting system would be the best way for me to make the game, however, I was unsure if lua or any other scripting language had greater speed when it came to actual gameplay.
speed comes first, and if lua is optimized (or whatever you might call it), then I would most definitely go with that.
Any help would be appreciated. Thank you,
-g-man
|
|
Back to top |
|
|
Ninkazu Demon Hunter
Joined: 08 Aug 2002 Posts: 945 Location: Location:
|
Posted: Thu Aug 07, 2008 5:54 am Post subject: |
[quote] |
|
LUA is the most optimized and minimalistic of scripted languages out there.
Given computational benchmarks, compared to C, LUA was 30x slower, while Python was 200~x slower. Java with its JIT magic was 7x slower.
A very large amount of professional games out there use LUA. See: WoW, Crysis, Ragnarok Online
For more see
http://en.wikipedia.org/wiki/Lua_(programming_language)#Games
With a clever assortment of custom API calls into your engine, you can make LUA work to your advantage and efficiency.
Believe me when I say that LUA is extremely easy to work with and learn, and is a much better alternative to a phoned-in solution most would likely dream up during their 20 minutes of design time allocated to the scripting engine. Upon poorly thought out design, you get incomplete and inefficient implementations even after a large amount of effort.
You want to make a game, yes? Learn to use tools that exist to your advantage. If you want to learn about writing your own interpreter/compiler/assembler, take a class, read a book, or make that your prime goal of a particular project.
After years in software, I really have learned that the #1 desired trait of any software engineer is to be able to deliver. Produce. Ship. You can find you've made a huge mistake in hiring the brilliant guy who can't get shit done over the recent college grad that's completed 10 large personal projects with a GPA of 2.9.
I'll reiterate. Games are probably the largest undertaking of any software developer and often involve a formidable amount of specialized technologies. If your goal is to learn rather than create, concentrate on a single area and make that your project rather than trying to single-handedly outdo Chrono Trigger.[url][/url]
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
Posted: Thu Aug 07, 2008 8:48 am Post subject: |
[quote] |
|
I think that it is important to first ask yourself WHY you need a scripting language.
If you're just a lone dev, and you're not planning to have other people create mods for your game, you don't really need a scripting language at all. All it will do is slow you down. You're better off with a couple of simple text-based data file formats, which you make dynamically reloadable.
One reason to use scripts, is if you have non-programmers who will be making the game specific scripting. In that case, general purpose scripting languages like LUA is no good - it's too complicated and not specific enough to your game, so you're better off making your own (SIMPLE!) scripting language, with the exact functionality you need and nothing more.
If the people making the game specific scripts for your game are programmers, they will prefer working in the normal IDE, and this will generate the fastest code too.
I guess integrating a general purpose script language such as lua can be fun, but it doesn't really give you an advantage, an I'd say you're better off just working on the game. _________________ www.mattiasgustavsson.com - My blog
www.rivtind.com - My Fantasy world and isometric RPG engine
www.pixieuniversity.com - Software 2D Game Engine
|
|
Back to top |
|
|
Ninkazu Demon Hunter
Joined: 08 Aug 2002 Posts: 945 Location: Location:
|
Posted: Thu Aug 07, 2008 4:07 pm Post subject: |
[quote] |
|
I wholeheartedly disagree. Throwing away scripting makes content generation a nightmare. You end up having a large amount of bloat in your engine to support new formats of data, and cutscene-type events and event simple dialog can turn out to be a huge pain to write. You essentially still have to write a semi-scripting language.
A simple scripting language as you say can easily be emulated in LUA, however in LUA you have access to far better resource management and expression evaluation (say you have some previous event requiring something else to happen and you need the same amount of gold rings as party members).
LUA IS simple. It takes about 10 lines of code to load it all up, and 1 more to launch a script.
The time to learn LUA would be less than a third it would be to write up and debug a "simple" scripting language.
|
|
Back to top |
|
|
Jinroh Scholar
Joined: 30 May 2008 Posts: 173 Location: U.S.A.
|
Posted: Thu Aug 07, 2008 5:24 pm Post subject: |
[quote] |
|
Personally I like the Mad Libs Style Scripting that Jim Adams proposes and implements in Jim Adam's Programming Role Playing Games With DirectX.
I made a variant of it with BASIC Syntax and what not I just haven't gotten to actually stick the class in my engine yet. _________________ Mao Mao Games
The wolf and his mate howl, taking solace in the silver moon. Pressing ever foreward to see what the future holds.
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
Posted: Thu Aug 07, 2008 6:57 pm Post subject: |
[quote] |
|
Ninkazu wrote: | I wholeheartedly disagree. |
Most engine programmers tend to do. But ask a C++ programmer to implement game logic in LUA, and he won't like it one bit. Ask a non-programmer to write game logic in LUA, and he'll say "no, I can't".
Ninkazu wrote: | Throwing away scripting makes content generation a nightmare. |
Content generation IS a nightmare, scripting or no scripting.
Ninkazu wrote: | You end up having a large amount of bloat in your engine to support new formats of data, and cutscene-type events and event simple dialog can turn out to be a huge pain to write. |
No, there won't be any bloat in the engine, but there will be lots of game specific code in your game. Which is ok.
Things like dialog and cutscenes don't need to be hard coded - those are things which a custom text-based data format are perfect for.
Ninkazu wrote: | You essentially still have to write a semi-scripting language. |
In a way, yes. But it will be one that gets the job done.
Ninkazu wrote: | LUA IS simple. |
I've used LUA for 4 major commercial retail projects. I think it's simple for a general purpose scripting language, and there's no other general purpose language I'd recommend in its place. But in my (quite extensive) experience, it doesn't make the job of making a game any easier. Well, it does make it easier for the engine programmer, but not for anyone else involved.
Ninkazu wrote: | The time to learn LUA would be less than a third it would be to write up and debug a "simple" scripting language. |
If you're already a programmer, you'll prefer using your main IDE/compiler. If you're not, you're not just looking at learning LUA, you're also looking at learning programming to begin with. _________________ www.mattiasgustavsson.com - My blog
www.rivtind.com - My Fantasy world and isometric RPG engine
www.pixieuniversity.com - Software 2D Game Engine
|
|
Back to top |
|
|
valderman Mage
Joined: 29 Aug 2002 Posts: 334 Location: Gothenburg, Sweden
|
Posted: Thu Aug 07, 2008 11:27 pm Post subject: |
[quote] |
|
Quote: | But ask a C++ programmer to implement game logic in LUA, and he won't like it one bit. | No, because a "C++ programmer" would be too stuck in his little C++-only world do get anything of value done at all. A programmer, on the other hand, would likely leap at the chance to get away from the horrors of C++.
Quote: | Ask a non-programmer to write game logic in LUA, and he'll say "no, I can't". | Even the densest non-programmer in the world would find little difficulty writing mathematical expressions and simple lines like setPlayerGold(10).
Quote: | No, there won't be any bloat in the engine, but there will be lots of game specific code in your game. Which is ok. | No, because you'll have to recompile quite a lot of code just to implement a simple change in AI, battle logic or anything like that.
Also, heaping everything into your engine is about the worst thing you can do from a code reusability standpoint. And before you say "oh, you can't reuse code anyway," might I suggest that the Gamebryo engine is a good reason why you're wrong? If that engine can drive games as diverse as Oblivion, Civilization IV and Zoo Tycoon, then surely reusing an engine of your own making for a couple of different RPGs wouldn't be that hard, would it?
Quote: |
Things like dialog and cutscenes don't need to be hard coded - those are things which a custom text-based data format are perfect for. | Many types of game logic is data. I see no reason at all why every single change to any part of the game's logic, no matter how tiny, should result in a lengthy recompile.
Quote: | In a way, yes. But it will be one that gets the job done. | Yes. Unfortunately, you won't get anything done since you rather reinvent the wheel than get on with your game.
Quote: | If you're already a programmer, you'll prefer using your main IDE/compiler. | In fact, I prefer not using a compiler at all. _________________ http://www.weeaboo.se
|
|
Back to top |
|
|
DeveloperX 202192397
Joined: 04 May 2003 Posts: 1626 Location: Decatur, IL, USA
|
Posted: Fri Aug 08, 2008 12:33 am Post subject: |
[quote] |
|
wow this is turning into quite the little tit-for-tat argument. :P
As a programmer who uses several languages, let me toss in my $0.02.
I am against hard-coding game data / logic into the game. Using scripting is so much better. However this approach only applies if you are writing your game in a compiled language.
I myself have all but quit using compiled languages for my game projects, and now I use what is considered to be a scripting language, though I think of it as just a really easy to use, and easy to learn programming language with which anything is possible. (Ruby if you're wondering.)
I have used LUA, and have used TCL, and I have used Python, all in the context of using it for scripting, as well as using it to write the whole game.
My personal experience has been that it depends on the overall goal that you are aiming for.
If you are trying to make a reusable engine, then build into that engine a way to script it using whatever language you want.
If you are just trying to make a game such as for a contest or just for the hell of it, then do not bother with adding a scripting layer to your game, just write the game in the scripting language to begin with.
Recompiling a project over and over to tweak any game data that has been hardcoded is STUPID. 100% utterly stupid!
The only time that hard coding the game data is not stupid is when the language that you are using is not compiled, hence its an instantly easily changed data.
Worried about someone seeing your code? Buy a commercial obfuscater that makes your code unreadable by 9/10 of the people who would try to mess with it. (Just don't forget to keep a backup of the readable code on hand for later changes if needed)
My final thing to say is. C++ while powerful is a terrible language to write games in. Period. Its great to write game engines with, and its great for writing apps that must be fast as hell. Just do yourself a favor and don't try to write a game in C++ its not worth it. _________________ Principal Software Architect
Rambling Indie Games, LLC
See my professional portfolio
|
|
Back to top |
|
|
RedSlash Mage
Joined: 12 May 2005 Posts: 331
|
Posted: Fri Aug 08, 2008 1:53 am Post subject: |
[quote] |
|
Quote: | Things like dialog and cutscenes don't need to be hard coded - those are things which a custom text-based data format are perfect for. Quote: | Many types of game logic is data. I see no reason at all why every single change to any part of the game's logic, no matter how tiny, should result in a lengthy recompile. |
|
This is how I do it... it doesn't require a recompile. Perhaps what Matt means by not using scripting is like placing dialogs and stuff in data files, for example XML files, and the XML provides your engine with enough info to carry out its task. No recompilation necessary and can be modified easily. The hardcoded parts would be how the engine interprets the XML file. This is how my game works (but I don't use XML for various reasons).
Quote: | C++ while powerful is a terrible language to write games in. Period. Its great to write game engines with, and its great for writing apps that must be fast as hell. Just do yourself a favor and don't try to write a game in C++ its not worth it. |
I like C++ though.
|
|
Back to top |
|
|
Gardon Scholar
Joined: 05 Feb 2006 Posts: 157
|
Posted: Fri Aug 08, 2008 1:59 am Post subject: |
[quote] |
|
I think C++ is essential in writing games. I'm only a casual programmer, but I think the speed is necessary compared to something like Basic or straight up script programming (perhaps in ruby). Plus it gives me something to work on and design since I can't make artwork for shit. I guess I like keeping busy with the code :)
|
|
Back to top |
|
|
Mattias Gustavsson Mage
Joined: 10 Nov 2007 Posts: 457 Location: Royal Leamington Spa, UK
|
Posted: Fri Aug 08, 2008 8:58 am Post subject: |
[quote] |
|
In my experience, most people who recommend the use of extensive scripting, are people who either haven't been through the whole process of making games, or people who have not worked on all parts of a game, even if they are often experienced programmers. I'm not saying this applies to those who have posted in this thread (I don't know what games you've worked on, so I wouldn't know), but it's a general observation.
Scripting is one of those things that seem like a neat concept, and looks like it could save a lot of time (it's particularly easy to get this impression early on in development).
Again, in my experience, it's often the case that scripting is more problem than it's worth. Custom made, very precise script systems can be worth their weight in gold. General purpose scripts though, is what I recommend against, as I've seen it tried and failed over and over again. I even worked on one big, AAA title where scripting went so out of control that the project was dropped altogether - it was considered to be so much work to put it right that it wasn't worth doing. In this case, the LUA scripts had kept growing and growing, doing more and more things, and never working quite right....
I'm not trying to convince those here that have their minds set on the usefulness of scripting - I'm merely sharing my negative experiences with it, in the hope that some people reading this might take a bit of time to think through, one more time, what they hope to achieve by adding script support, and whether general purpose scripting is really the solution to this.
Saying "just use LUA, it's the best and fits every game" is not good advice, in my opinion.
valderman wrote: | No, because you'll have to recompile quite a lot of code just to implement a simple change in AI, battle logic or anything like that. |
Not really. Edit and continue is a great feature of Visual Studio. Just set a break point, change the code, click Apply changes, and continue running.
valderman wrote: |
Also, heaping everything into your engine is about the worst thing you can do from a code reusability standpoint. |
Why would you want to do that? Putting all your game code into your engine/libraries? That's just weird :-)
The game is not just made up of the engine though - it's mostly made up of the game code, which calls engine functions. And heaping game functionality into the game is just... well... making the game really :-)
valderman wrote: | And before you say "oh, you can't reuse code anyway," might I suggest that the Gamebryo engine is a good reason why you're wrong? If that engine can drive games as diverse as Oblivion, Civilization IV and Zoo Tycoon, then surely reusing an engine of your own making for a couple of different RPGs wouldn't be that hard, would it?
|
I think code reuse is highly overrated. A lot of game specific code will never have to be reused, and it's just a waste of time writing it such that it can be.
That being said, low-level library code (graphics/sound/input) should definitely be reused. Some mid-level code, like scenegraph, pathfinding, file formats etc, are also good candidates for reuse - though you would obviously want the option to modify and adapt them to suit the needs of individual games.
I've worked with Gamebryo btw. I was lead programmer on this project, so I'm quite familiar with how it works. And let me tell you this: I'd guarantee that the games you listed, are not just using Gamebryo out of the box. They've used it as a base, a starting point, and then built their game engine on top of it, and their game on top of that.
One thing they haven't done though, is just plugged in LUA and handed the whole thing over to the scripters. It's a little more involved than that. _________________ www.mattiasgustavsson.com - My blog
www.rivtind.com - My Fantasy world and isometric RPG engine
www.pixieuniversity.com - Software 2D Game Engine
|
|
Back to top |
|
|
Nodtveidt Demon Hunter
Joined: 11 Nov 2002 Posts: 786 Location: Camuy, PR
|
Posted: Sun Aug 10, 2008 4:10 am Post subject: |
[quote] |
|
Without getting into yet another language war here...my opinion is that you use the tool for the job. Lua seems to be a good general purpose tool but it's not suited for every project and seems to be rather ho-hum for games (though better than most prebuilt dialects). C++ is for people who want to distance themselves from the lower levels of computing, and want the ease of objects. But the only thing "fast" about C++ is the speed of development compared to low-level procedural languages...and that only applies if you're a C++ expert. C++ compilers tend to introduce way too much overhead (which creates performance bottlenecks), and the dialect itself is a bloody mess, especially if you come from the *logical* world of procedural programming (anything you do in C++ can be done in C...if you know how). In the end though, it all boils down to what YOU think is best for your project. _________________ If you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows. - wallace
|
|
Back to top |
|
|
valderman Mage
Joined: 29 Aug 2002 Posts: 334 Location: Gothenburg, Sweden
|
Posted: Sun Aug 10, 2008 9:34 am Post subject: |
[quote] |
|
Nodtveidt wrote: | Without getting into yet another language war here...my opinion is that you use the tool for the job. Lua seems to be a good general purpose tool but it's not suited for every project and seems to be rather ho-hum for games (though better than most prebuilt dialects). C++ is for people who want to distance themselves from the lower levels of computing, and want the ease of objects. But the only thing "fast" about C++ is the speed of development compared to low-level procedural languages...and that only applies if you're a C++ expert. C++ compilers tend to introduce way too much overhead (which creates performance bottlenecks), and the dialect itself is a bloody mess, especially if you come from the *logical* world of procedural programming (anything you do in C++ can be done in C...if you know how). In the end though, it all boils down to what YOU think is best for your project. | I strongly disagree with just about everything in this post. C++ is definitely not very distanced from low-level programming, the speed of development with it is glacial compared to high level languages such as C#, Java, Python, etc. and its performance is close to that of C if you know how to use it more or less properly. The only point where we agree seems to be that it is a bit of a tangled mess. _________________ http://www.weeaboo.se
|
|
Back to top |
|
|
RedSlash Mage
Joined: 12 May 2005 Posts: 331
|
Posted: Sun Aug 10, 2008 10:27 am Post subject: |
[quote] |
|
A note about C++ and speed: the "fast" part of C++ is more to do with the skill of the programmer, than it is of the language itself. A novice programmer will likely produce a slower, more buggier and memory-leak riddled program when programming in C++ but will produce a decently performing program with lesser bugs and in shorter time using a higher leveled, managed language like Java and C#. For C++, you'd have to push your knowledge to the limit and be an expert skilled C++ programmer with years of experience if you want the speed advantage that is worth your development time.
As for scripting, scripting is very useful when you want to allow people to extend the functionality of your game. Whether Gardon needs scripting or not, if he chooses to use it, it is probably better to use LUA than to write his own unless he just wants to do it for fun or requires something that LUA cannot provide. There's really no reason to reinvent the wheel. As for LUA alternatives, anyone have experience with NekoVM?
|
|
Back to top |
|
|
Hajo Demon Hunter
Joined: 30 Sep 2003 Posts: 779 Location: Between chair and keyboard.
|
Posted: Sun Aug 10, 2008 11:17 am Post subject: |
[quote] |
|
In my former project H-World, at least in the design stage, I wanted to keep my engine closed source and scripting was meant to provide the extensibility and adaptability that game and mod makers will need.
Speed or ease of development were not the drivers of choosing a scripting approach, but the separation of closed and open parts was.
Lua worked fine there. I liked the way it integrated with C/C++, and it seemed to be sufficiently performant.
I just tell this to show that some projects chose scripting for reasons that have not been pointed out in this thread yet, and for some projects they may be valid. In my case it turned out to be a moot point though, since H-World now is open source, so there is no "closed" part anymore, and my new project Sonnheim is also open source - with open engines the need for scripting is lower, I think. But I also moved from C++ to Java, since in my experience development is quicker with Java, and Java programs are more robust, overall Java has less ways to make mistakes than C++ has (at least for me).
|
|
Back to top |
|
|
|
Page 1 of 3 |
All times are GMT Goto page 1, 2, 3 Next
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|