Sign in to follow this  
Justin2006

Help making a new scripting language?

Recommended Posts

I've been planning on making a new scripting language for a game I'm working on.. and well I'm looking for any articles or discussion on design/optimization of a compile/execute engine. The design concept I was thinking about was similar to what I know about Java and would be used similarly like UnrealScript. I was thinking of using a file header system similar to windows PE headers and allowing for importing/exporting of existing 'symbols' from other scripts running on the VM. Then I was hoping to write it in a way that classes available in C++ can be used in the script such as: class SObject { //... }; Then the script could use these functions and further define their own ( add to it.. using inheritance ) then when another class uses this inherited class, it can call on the new functions which override the old ones. Basically if I did this: class SObject { protected: public: int SomeFunction( ) { return 1337; } }; then in my script: exported class SomeClass { private SObject object; public integer getValue( ) { return object.SomeFunction( ); } } then getValue would return 1337 but: exported class NewObject inherits SObject { public integer SomeFunction( ) { integer value = old.SomeFunction( ); return value + 1; } } then this SomeFunction when called by another class would return 1338. Basically the syntax would be similar to C++ with typecasting and objects etc. The existing classes will be defined in C++ and all of their functions and public data will be visible to these functions. Now that's pretty simple... Not too difficult.. I believe I can do that with no problems. What I need to learn about is compiling/executing methods. I was thinking something like ( note this isn't what I'm using, it's simply psuedo ): struct ScriptExHeader { unsigned long version;//version of the script compiler unsigned long baseAddr;//base address ( preferred base address ) unsigned short numSections;//number of sections within the file unsigned long secTable;//offset of table listing sections unsigned long importsTable;//offset to table listing imports unsigned long exportsTable;//offset to table listing exports }; struct ScriptExSectionEntry { //first one at script base addr + secTable ... simple things }; You know standard header stuff.. then the sections would be code and data sections and then space for created objects etc. Then how would I interpret the sections with code.. should I use an opcode system like ASM is and have scripts be something like: //function in a class $//this symbol is the start of a func perhaps? //integer num = 123; <2bytes=mov opcode><2bytes=describe>:mov [dataPointer+<size of integer>] //return num <2bytes=mov opcode><2bytes=describe>mov returnRegister,[dataPointer+<size of integer>] Just curious if there are some articles on this.. if so I'd much appreciate if you'd post some. I'm really not sure what I should do or any ideas of optimization for speed or size. It's not really a perfect design I'm going for, just something that does what I need it to :) Thanks - Justin

Share this post


Link to post
Share on other sites
Yes! Take a look at the link in my post here (it's lonely [lol]). On that site they have a massive scripting section that you might find interesting. Definitly give it a try out [smile]. I believe there are also some great articles on this topic on GameDev as well. Here's one of them, there are many others, but I don't know where they are all, definitly take a look at the "Articles" at the top bar under "Resources".

Share this post


Link to post
Share on other sites
Quote:
Original post by Justin2006
I've been planning on making a new scripting language for a game I'm working on..


Are you making a new scripting language or a game? If scripting language, then have fun and enjoy, but if you are making a game, then why re-invent and waist you time to create new script, rather then use existing one. Call me crazy but I have far more fun making game and use OPT (Other People Technology) then re-inventing the wheel and spend my time on debugging that new wheel.

Share this post


Link to post
Share on other sites
If you want a good, relitively fast interprited language, i would sugest you go for a lisp derivitive.

Its very simple, and (If you looks at my language idea), everything is changable via symbol tables. (including functions. Could come in handy later).

Its also dead easy to program. (the actual interpriter. As well as the scripts).

It jsut takes a little getting used to, if your used to C, vb, java, ect.

From,
Nice coder

Share this post


Link to post
Share on other sites
Quote:
Original post by STLDude
Are you making a new scripting language or a game? If scripting language, then have fun and enjoy, but if you are making a game, then why re-invent and waist you time to create new script, rather then use existing one. Call me crazy but I have far more fun making game and use OPT (Other People Technology) then re-inventing the wheel and spend my time on debugging that new wheel.


Well.. I'm working on it myself to strengthen my understanding in all the areas of making a game. And who knows, after I finish it.. it could be big? Maybe some company will see it and say "YOU'RE HIRED!" lol. I'm not really re-inventing the wheel.. per-say.. The system I want is a bit different than other scripting languages I've looked at and I don't feel like taking OPC ( lol ) and re-writing only parts of it to make it do what I want and possibly messing it up since I don't know what all of it does. If the game itself is written through scripts and I use DirectX ( DirectInput, DirectConnect, DirectSound.. ) at the base it's not much of a hassle to make a simple FPS game. I'm not shooting for UT2k4 lol, it's just a little project to work on in my spare time ;)

Share this post


Link to post
Share on other sites

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