Archived

This topic is now archived and is closed to further replies.

A good game scripting language - how should it look like?

This topic is 5127 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

What features would YOU like to see in a game scripting engine? How should the syntax be like? Should the scripts be translated to bytecode? Throw in your thoughts on the subject. "On a long enough timeline the survival rate of everyone drops to zero" - Fight Club

Share this post


Link to post
Share on other sites
Bytecode could be good to obtain more speed then on the fly analyses of the script text. But the best way to do it is to convert your script into a C++ dll project and then compile it with an actual c++ compiler. But off course that''s not an easy thing to do.

Also make sure you allow object oriented script programming, because it gives a lot more power to the scripting language. Especially because it''s meanth for a whole engine, I would certainly use OO scripting. If you only use it for e.g. the rendering loop, it wouldn''t be necessary imho.

"My basic needs in life are food, love and a C++ compiler"
[Project AlterNova] [Novanet]

Share this post


Link to post
Share on other sites
I think general gamescripting languages aren''t the way to go, surely a specific game or engine will have it''s own specific language, if you aremaking one for general use, ensure it''s extensible, easy to learn and easy to use. Speed should be considered, the bytecode option would probably be best; ie: Your script compiles to a set of bytecode instructions, probably using a virtual stack of some sort. When I get round to making a scripting language for Manta-X, I''ll be making the script language akin to basic, covering only the main functions of the game.

It should ideally allow users to specify functions and set aside specific events that the game uses.

eg:

Event KeyPress(k)
if k = ''a''
call some_function
end if
End Event

Share this post


Link to post
Share on other sites
I am thinking genral use - as a dll. It should definently be oop if you ask of my opinion. One of my ideas is that the programmer of the game should be able to create objects and functions in the script enviroment from his C++ code or whatever language he/she is using. IE you use a script to create a bot and the bot interacts with the game using functions defined by the game programmer in his/her game code.

Share this post


Link to post
Share on other sites
quote:
Original post by downgraded
I think general gamescripting languages aren''t the way to go, surely a specific game or engine will have it''s own specific language, if you aremaking one for general use, ensure it''s extensible, easy to learn and easy to use. Speed should be considered, the bytecode option would probably be best; ie: Your script compiles to a set of bytecode instructions, probably using a virtual stack of some sort. When I get round to making a scripting language for Manta-X, I''ll be making the script language akin to basic, covering only the main functions of the game.

It should ideally allow users to specify functions and set aside specific events that the game uses.

eg:

Event KeyPress(k)
if k = ''a''
call some_function
end if
End Event



Odd that you should metion that. Sierra made all their award winning games using the same scripting language...




[Cyberdrek | the last true sorcerer | Spirit Mage - mutedfaith.com][ Administrator & WebMaster GuLSE]

Share this post


Link to post
Share on other sites
quote:

So you essentially "expose" your classes to the script? You''d have to declare each member as some form of functor / variable hook.


I would do something like this:

//C++:

script->AddFunction([void function(void) pointer],"name");

//my script:

import name;
name();


"Stop trying to hit me and hit me!"

Share this post


Link to post
Share on other sites
I believe that scripting languages should be simple. No Object oriented or whatsoever. What is the use of it then? Why don''t you just use c/c++ and link it?
I must be honest that scripting is number 4 on my to do list so I haven''t looked all too much into it.

Look at all the pretty colours!

Share this post


Link to post
Share on other sites
quote:
I believe that scripting languages should be simple. No Object oriented or whatsoever. What is the use of it then? Why don''t you just use c/c++ and link it?


I would disagree - it would be better to have object based scripting for exactly the reasons that object coding gives (ie. collecting variables together into a relevant namespace).

This is how I work when doing simulations - expose objects rather than variables - because then the user knows exactly what belongs to what.





"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan

Share this post


Link to post
Share on other sites
From SWING''s site:
SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.

Seems like a good thing but it should be benchmarked.
I think it could be nice to implement the script as co-routines as proposed by Thomas Tong in http://gamedev.net/reference/programming/features/cscript/
but perhaps instead of requiring the user to know C/C++ and have a real compiler, just to have a compiler of our own script language to generate the assembly (thus needing only an assembler) to spit out the code. Can this be feasible? Is it too hard to generate assembly for a .dll or a .so?

Carlos

Share this post


Link to post
Share on other sites
quote:
Original post by crypticmind
Seems like a good thing but it should be benchmarked.



Sure, you can do it. I won''t, I don''t need any convincing.

quote:

have a compiler of our "own script"


Yes, everyone should learn everyones proprietery scripting language. That''s practicle! Why not support swig and let the user decide which scripting language they want to use. They might even choose a standard language for instance. Wouldn''t that be grand.

quote:

just to have a compiler of our own script language to generate the assembly (thus needing only an assembler) to spit out the code. Can this be feasible? Is it too hard to generate assembly for a .dll or a .so?



Sure why not, oh yeah, forgot about interfacing the binary code to the memory model, control flow, etc, of the os. And then restart from scratch for another OS. Oh the humanity! Hey let''s all make our own vitual machine. I''ll get right to it.

No I won''t.



Share this post


Link to post
Share on other sites
quote:

Odd that you should metion that. Sierra made all their award winning games using the same scripting language...



And don''t forget the Lucasarts adventures using the SCUMM VM.

As for languages: how about just writing your own (stripped-down) Java-style VM, that way you can let people use a standard grammar for scripts (Java) and you can let the Java compiler do all the nasty bytecode compilation for you.

Share this post


Link to post
Share on other sites
quote:
Original post by BrownBean
quote:
Original post by crypticmind
Seems like a good thing but it should be benchmarked.


Sure, you can do it. I won't, I don't need any convincing.



You are confident of its speed. Good for you! Perhaps instead of just throwing an url, you could mention if it's speed is enough as for the main game loop.

quote:

Yes, everyone should learn everyones proprietery scripting language. That's practicle! Why not support swig and let the user decide which scripting language they want to use. They might even choose a standard language for instance. Wouldn't that be grand.



No, no one should learn no ones proprietary scripting language. "Or own script" != "proprietary non-standard language", I meant a language proccessed by ourselves.

quote:

Sure why not, oh yeah, forgot about interfacing the binary code to the memory model, control flow, etc, of the os. And then restart from scratch for another OS. Oh the humanity! Hey let's all make our own vitual machine. I'll get right to it.



Ok, I admit it may be too much for you. But I'm not the only one who will try this kind of stuff. People are commenting about java-vm, other co-routines in c++, etc. We all want the benefits of scripting, but we can't sacrifice speed in favor of giving the users much types of script to choose for. Maybe you like very much swig and don't want to try anything else...

quote:

No I won't.



Ok.
I think swig is a very fine product and I may support it. But for now, all I can say is that this is game programming and you can't be serius at it if you are scared by things like a virtual machine.

[edited by - crypticmind on November 25, 2003 3:40:01 PM]

[edited by - crypticmind on November 25, 2003 3:45:38 PM]

Share this post


Link to post
Share on other sites
quote:
What features would YOU like to see in a game scripting engine? How should the syntax be like?
quote:
Yes, everyone should learn everyones proprietery scripting language. That's practicle
Am I the only one not quite getting this?

True: I am making a scripting engine for games. Since I will not be doing all the scripting I would like to get some input from people interested in game development so that the scripting may be suited for them and the job they are doing. If youre gonna do something - why not do it good?

False: I am making a new scripting language which I will insist on people using and throw echonomical sanctions at those who do not. Finally the scriping language will be yet another addition to Microsoft Internet Explorer known as the scripting language "Mokka Script".

[edited by - emileej on November 25, 2003 6:51:13 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by crypticmind
Ok.
I think swig is a very fine product and I may support it. But for now, all I can say is that this is game programming and you can't be serius at it if you are scared by things like a virtual machine.




Hey crypticmind, I apologize for being sarcastic. But I felt that you commented before even reading their documentation.

On the contraire, I do want to do everything. But at somepoint in all our lives, you realise that you can't do everything. I have the knowledge to make my own console and make games for it. It wouldn't be more powerfull than an original gameboy and I did realise that it's just too much. Not to mention costly.

You decide what you want to do: a game or the technology. Trust me on this one, alone, especially when you are learning, you can't do all.

Just out of curiosity, did you write a virtual machine? Did you even write a compiler that works? Not just one that blurts out assembly to binary, but one that can be used in an 32 bit operating system. They are not easy at all, and very time consuming. So you gotta figure out what you want to learn.

quote:
You are confident of its speed. Good for you! Perhaps instead of just throwing an url, you could mention if it's speed is enough as for the main game loop.



First you don't put scripting in the main loop of any game at all!. Second, I wasn't going to put their documentation on a post. But, I do admit I should have written a bit more.

quote:

No, no one should learn no ones proprietary scripting language. "Or own script" != "proprietary non-standard language", I meant a language proccessed by ourselves.



Unless your script is like C, C++, java, javascript, pascal, basic, (can't name them all ), isn't it your own prorpietery language...

What do you mean a language processed by ourselves? Do you mean your own engine that processes the script? In that case, say you support a standard language, can someone take an already existing, working code and run it in your engine. To make it easier, say that code wouldn't have any input or output with the consoles.

Again, I apologize for for being sarcastic.

[edited by - brownbean on November 25, 2003 10:13:08 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by BrownBean
You decide what you want to do: a game or the technology. Trust me on this one, alone, especially when you are learning, you can''t do all.



You''re right on this...

quote:

Just out of curiosity, did you write a virtual machine? Did you even write a compiler that works? Not just one that blurts out assembly to binary, but one that can be used in an 32 bit operating system. They are not easy at all, and very time consuming. So you gotta figure out what you want to learn.



I had to write both (but for Linux, it''s easier), I''m on comp. sci.

quote:

Unless your script is like C, C++, java, javascript, pascal, basic, (can''t name them all ), isn''t it your own prorpietery language...

What do you mean a language processed by ourselves? Do you mean your own engine that processes the script? In that case, say you support a standard language, can someone take an already existing, working code and run it in your engine. To make it easier, say that code wouldn''t have any input or output with the consoles.



Ouch!

Share this post


Link to post
Share on other sites
quote:
Original post by emileej
I am making a scripting engine for games. Since I will not be doing all the scripting I would like to get some input from people interested in game development so that the scripting may be suited for them and the job they are doing. If youre gonna do something - why not do it good?

Without specifying what kind of game you want to use it for, I can''t give you a good answer.

If your answer is ''any game'', then I''d just say ''Python'' or ''Lua''. These are optimised languages for generic scripting and can do pretty much anything well.

If you have a particular type of game in mind, then my answer might change. For example, if it was purely for AI then I might want a language with inbuilt state-machines like UnrealScript. A language designed for scheduling periodical future events might require good multithreading with automatic synchronised access to data structures. It might also use generators to store state across subsequent calls instead of having to temporarily associate arbitrary data with the object.

Whether the scripter thinks it should be compiled to bytecode or not is irrelevant though. As the language developer, you need to decide whether that step is necessary or not.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
May have been said, but access to all your c++ code (functions and classes varibles etc)

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
It should look just like Python


Agreed.

I really think that any scripting engine used in a game should compile the scripts to bytecode. That''s a must for me. When it comes to syntax, I like the semi-procedural / semi-OO approach. The engine should be small and concise, and bloat-free (kind of rules python out, I guess).

Share this post


Link to post
Share on other sites
I''m knocking a small script engine together now, it compiles to a VM byte-code on a stack-based machine with predeclared variables. Each script has it''s own execution stack, etc. Variables can be shared from one script to another (or they will be, eventuually).

It''s fairly nice to only have a few set types to worry about (here I have strings, floats and longs).

When adding callback functors to game functions, would you allow the game code to have direct access to the variables, or would you pass them by value to the game, requiring that if they need to change them, they have to call a script->SetVar() function. I suppose this way, it makes things a little safter, stopping games accidentally destroying the script and it''s stacks

Share this post


Link to post
Share on other sites