Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411275 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 09:58:08 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Scripting?
Pages: [1]
Print
Author Topic: Scripting?  (Read 4748 times)
clevceo
Level 0
*


View Profile
« on: December 29, 2007, 03:28:08 AM »

I'm planning to implement some scripting in my game, and I'm going to read up on Lua, but I was wondering if I could get some input on scripting in general before I get in over my head.

Is Lua the way to go?  I know Aquaria used it.  Also, are there any simple tutorials aimed at indies?

Thanks,
clevceo
Logged
spellcaster
Level 0
**



View Profile
« Reply #1 on: December 29, 2007, 07:18:14 AM »

Lua is really simple to integrate in a C/C++ game.
So is python.

Right now I'd say your best choices are:
1) Lua
2) Python
3) JavaScript (using spidermonkey)

It depends on what you want to do with the scripts, what language you prefer, etc.
Logged
gummikana
Level 3
***



View Profile WWW
« Reply #2 on: December 29, 2007, 07:32:21 AM »

Also every real programmer writes at least one new scripting language...

(I don't recommend doing that if you want your game done, but it's a good learning progress).
Logged

Petri Purho
jankoM
Level 0
***


Beat around the bushes


View Profile WWW
« Reply #3 on: December 29, 2007, 08:28:31 AM »

Lua is nice to embed... I heard python is a little harder (the snake prefers to be extended not embeded if I remember correctly Wink ).

When I tried to embed a scripting thing into c++ app I was decidig between lua and newo vm . I went with neko then because their c FFI seemed even more straightforward than Lua's.. I managed to embed the nekoVM (http://nekovm.org/doc/vm) in couple of hours although I suck at c++ (http://nekovm.org/doc/ffi).

NekoVM currently has 3 languages ... the Haxe (like AS3 or EcmaScript), nekoML and this core lang of neko itself that is quite interesting too.

I heard spidermonkey is very resource hogging thing compared to lua. Lua is probably the fastest of these and some say it's the fastest dynamic/scripting lang currently. Neko should also be quite fast and resource friendly I think.
Logged

clevceo
Level 0
*


View Profile
« Reply #4 on: December 29, 2007, 01:35:59 PM »

Does anyone know anything about Xnua?  I use XNA and I hear Lua isn't natively compatible, but Xnua is.  However, I hear Xnua has some differences.  Is it worth it, or should I use a different scripting language entirely?

clevceo
Logged
Bad Sector
Level 3
***


View Profile WWW
« Reply #5 on: February 19, 2008, 03:22:12 PM »

A little late, but i just logged and after a while and reading all front-page posts and decided to reply here in order to mention my own scripting engine, UndeadScript (page not IE6 friendly and doesn't love IE7 that much). It's a mix between Java and JavaScript, strong typed, object oriented with garbage collection and other nice stuff. I've used it in several projects and it's very portable (a friend of mine used it in a SGI Irix system with a big endian MIPS processor and personally i've compiled it in Windows, Linux, MacOS X and FreeBSD). The version in the above site is a little old and since then i've changed my mind about what "1.0" will be, so i really recommend you to get the latest development version from this site. Recently i dropped the need for 'bmake'.

If you want to see how the code looks like, check SiSIG, which is basically a simple wrapper around SDL (here is a little demo from a guy from a greek forum). Also my Nikwi game used a very early version of the language for monsters and entities.
Logged

~bs~
PoV
Level 5
*****


Click on the eye and something might happen..maybe


View Profile WWW
« Reply #6 on: February 20, 2008, 10:44:47 AM »

A couple more C/C++'ish scripting languages.

GameMonkey is one.  The authors seem to have as boring a Mobygames page as I.  Smiley

AngelCode is another.  AngelScript appears to do some really interesting things.  Binding C/C++ calls directly to the VM, instead of having to use a "proxy" function to call them.  I don't know it performs versus Lua, since it's not on the shootout, but it seems to be used in a few games.

Squirrel is yet another, by one of the programmers on Far Cry.  Has some thoughts about Lua.

But yeah, everybody seems to be turning to Lua these days, myself included.  So even if there is a faster language out there, Lua's been proven time and time again as a solid embeddable scripting language (for nearly 10 years).
Logged

Mike Kasprzak | Sykhronics Entertainment - Smiles (HD), PuffBOMB, towlr, Ludum Dare - Blog
Bad Sector
Level 3
***


View Profile WWW
« Reply #7 on: February 20, 2008, 04:39:37 PM »

Lua seems a nice little scripting language, but i really hate the syntax :-). I prefer C-like syntaxes and from all "major" scripting languages, imho Python is the best (but it's not "little"). Also is used by Blender (and maybe other tools) so if your artist(s) use the tool you can convince them to learn the language for it and for scripting the game :-)
Logged

~bs~
rodhyde
Level 0
*


View Profile
« Reply #8 on: February 21, 2008, 07:30:05 AM »

Is Lua the way to go?  I know Aquaria used it.  Also, are there any simple tutorials aimed at indies?

A question you might want to ask yourself is, "what are my requirements and constraints?"

For example, if size is an issue then Lua is small, but if you're looking for something expressive then you have to go a long way to beat Python.

--- Rod

Logged
PoV
Level 5
*****


Click on the eye and something might happen..maybe


View Profile WWW
« Reply #9 on: February 21, 2008, 05:17:56 PM »

... but if you're looking for something expressive then you have to go a long way to beat Python.

*Twitch*  Wink

Scripting languages in a game engine are for implementing high level specifics, not doing work.  "If" checks and function calling.  Any types you use are purely a convenience, and you should rarely loop. 

You can loop, and it's not like there is no looping.  Your script functions can and will be called multiple times by the engine.  And scripting a dialog tree/cut-scene can certainly be nicer with a concept of loops (and VM blocking), but you could always build a finite state machine ("If" checks with a "state" variable).

The point of a script is to allow customization of system behaviors, without hard-coding it in the engine.  A good scripting language integration hides the complexities of the engine, and lets you talk in high concepts.  Not to mention opening up rapid development/testing/deployment possibilities.

A script should dictate animation changes, not step the frames or the bones.  A script should pick the dialog, not draw the letters.  A script should call "sort", not store and implement an algorithm. 

You want to spend as little time running a script as possible.  The meaty code will still be in C or C++.
Logged

Mike Kasprzak | Sykhronics Entertainment - Smiles (HD), PuffBOMB, towlr, Ludum Dare - Blog
rodhyde
Level 0
*


View Profile
« Reply #10 on: February 22, 2008, 12:57:44 AM »

Yes, I agree 100%. That makes my point a lot more eloquently than I did.

Don't get me wrong - I think Python is God's own language - but I wouldn't use it for my rendering code.

--- Rod
Logged
jcromartie
Level 0
***


View Profile
« Reply #11 on: March 23, 2008, 11:13:57 AM »

... but if you're looking for something expressive then you have to go a long way to beat Python.

*Twitch*  Wink

Scripting languages in a game engine are for implementing high level specifics, not doing work.  "If" checks and function calling.  Any types you use are purely a convenience, and you should rarely loop. 

...

A script should dictate animation changes, not step the frames or the bones.  A script should pick the dialog, not draw the letters.  A script should call "sort", not store and implement an algorithm. 

You want to spend as little time running a script as possible.  The meaty code will still be in C or C++.

I'm wondering exactly how slow you think Lua is?  When it comes to modern games, a scripting system like Lua is not going to be much of a bottleneck.  While I don't think you should be doing any really complex graphical routines or anything like that, you can definitely implement all of the drawing logic and tile system for a 2D game in Lua.

I decided to to some tests to see where the bottleneck is.  On my aging 1GHz PowerBook I can draw three thousand 16x16 sprites with OpenGL at 60 frames per second from a Lua script.  Drawing fewer, say, 1000 sprites, runs at about 180 FPS.  Adding an arbitrary 10K-iteration loop to the drawing routine only brings it down to 160 FPS.  I think it's safe to say that moving all of that code to C wouldn't make much of an improvement.

The best optimizations to be made in game programming are in graphics and hardly ever in logic.
« Last Edit: March 23, 2008, 11:36:19 AM by jcromartie » Logged
Alec
Level 10
*****



View Profile WWW
« Reply #12 on: March 23, 2008, 10:48:18 PM »

Lua's been proven in a few games, I didn't have any problems with speed when using it.

The syntax is a little bit different from C, which can trip you up sometimes. How much that annoys people is down to personal taste.
Logged

jcromartie
Level 0
***


View Profile
« Reply #13 on: March 24, 2008, 04:49:31 AM »

Lua's been proven in a few games, I didn't have any problems with speed when using it.

The syntax is a little bit different from C, which can trip you up sometimes. How much that annoys people is down to personal taste.

It's also worth mentioning that it offers a lot of opportunities to use advanced concepts for the more advanced programmers out there.  It's functional, dynamic/loose typed, you can implement any kind of object system you want (prototype, multiple inheritance, etc.) with tables and metatables, and it's a great data-description and/or meta-programming language.  For instance, I have an in-engine map editor that simply writes Lua code which describes the layouts and their attributes.

Metatables + first class functions = the win.
Logged
Alec
Level 10
*****



View Profile WWW
« Reply #14 on: March 24, 2008, 05:05:31 AM »

Yeah, its crazy powerful. I know I haven't touched the really cool stuff yet. Smiley
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic