🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

The dominant language of an engine

Started by
12 comments, last by spiffgq 20 years, 11 months ago
Well one good use for a scripting language is a particle system.
You code with your scripting language what you want to do with your particles etc... I used this kind of a scripting language. Once coded the desired particle efect with the script language, I parse it to check that it stands for thr languages specification.

After parsing the command I insert it in a "lookuptable" holding the commands in the order that we want to process them(same as in the script code, normaly from up to down ).

What I'm trying to say here is that every command in the script language has an operation assigned to it by the engine. When you create the desired particle effect with your script you kind of tell the engine what to render, when, how etc..

The great thing about this is that you don't have to rebuild your engine code to make a change in a particle effect. Thing of the time you'll save and allso the size of your code and the size of your executable.

Now you don't have to stop here, you can create a scripting language that may operate on other things than particle effects.
Like model rotation, lightinh operations, pre data assembly, scaling etc..

I think that a well designed script language can save you time and effort and for what come to speed hit, well thats where you have to be creative with the rendering code that communicates with your script language.

As I said above some sort of a fast good optimized "lookuptable" will do the trick. Well I don't know that well, but with carefull coding, design, imagination and steel nervers i think you can create an good script language that will help you and your team alot of work.

Besides you can create a tool to handle the scripting language operations. Let's say a level editor that creates maps for you. You import model and put them in X place all over your 3D world. When you save the "map" in to a file you can use the script language to describe the models and their places.

And if you want to speed up the parsing of your script language, you should save the data in binary form.

Well dunno if this thoughts make any sense, but I think this kind of an approach will do well if it's done properly.

[edited by - LionheartAdi on June 17, 2003 5:55:06 AM]
Adrian Simionescu
Advertisement
ok, this thread contains pretty much what I wanted to know about scripting in games, but I just need to put a little fictional example to see if I''m getting it 100%.

Let''s say I''m making a 2D RPG in Java and I have a class Player that goes something like this:

public class Player {    //bunch of attributes    public Player(attributes) {        //initialize    }    public void foo(bar) {} //does something    public void foo2(bar2) {} //does something else} 


My question is: will the scripting language be used to call these Java functions?? For instance, to create a new character I could use:

terra = CreatePlayer("Terra", 5, 5, ...)

and the script would then call the code in Java:

Player p = new Player("Terra, 5, 5, ...)

or if I wanted to simplify something that requires more than one function could I do in the script:

doFooAndFoo2(bar,bar2)

and that would call the Java functions foo and then foo2??

I''ve thought about it and it sounds logical enough, so I asume that''s the real use of scripts. Am I right??

Thanks in advance guys!! (By the way, this is my first post! Hope to become a regular here!)

Mariano


---

"You want to live in this world the way it is? No? Then do something about it!"

Celes
---"You want to live in this world the way it is? No? Then do something about it!"Celes
Well, what I would do is hardcode a singleton 'resource manager' for all my objects (not necessarily ONE singleton, maybe a few, one for loadable resources, one for levels, etc etc) and then in the script go:
def SpawnPlayer( name, gun, location ):`     // spawn the player     Player = Entity.CPlayer( name, gun, location )          // add to entity manager     g_EntityManager.addResource( Player )`def UpdatePlayer( name ):`     // get the player     Player = g_EntityManager.getResource( name )     // update the player     if KeyDown( 'W' )          Player.moveForward()     ...


That's what I'd do (hope it's easy to read). That's simulaed Python btw ('simulated' to make it easier to read), my language of choice.

Chris Pergrossi
< ctoan >
My Realm

[edited by - c t o a n on July 17, 2003 9:03:23 AM]
Chris PergrossiMy Realm | "Good Morning, Dave"
Now, as to implementing a scripting language in my engine, Python takes care of virtually everything and like was said before, it only runs about 15 % slower. However, the cool thing about Python is that if it really runs just TOO slow, no problems, just rewrite it in C++ and export it as a DLL file. No changes to the script necessary and now you have C++ speed in Python flexibility. The coolest part about scripts to me is that they are so easy to use and don''t require a full recompile. For example, one of the artists that works with me loves to tweak things in the game, but we don''t have time to expose a full interface to do all the user-friendly tweaking. So we just got him a Python book and *poof*, he can tweak with the best of us! The limits with scripts are ENDLESS, you just gotta learn how to use them (easier said then done)

Chris Pergrossi
< ctoan >
My Realm
Chris PergrossiMy Realm | "Good Morning, Dave"

This topic is closed to new replies.

Advertisement