Jump to content
  • Advertisement
Sign in to follow this  
Medo Mex

Game Logic: Creating a Scripting Language

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

I'm creating my own scripting language for my 3D Game Engine, at first I'm doing lexical scan, then parsing the tokens.

 

What is your suggestions for creating a powerful scripting language for 3D Game Engines?

 

For methods, should I create bunches of methods linked to a callback?

 

I thought I could do something similar to the following:

parser.declareFunction("FunctionName", callback);

So when I execute parser.parse("bool b = true; if (b) { FunctionName(); }"); the callback should be called

Share this post


Link to post
Share on other sites
Advertisement

What Lorenzo said.  I would only recommend designing a new scripting language if it was truly a desire to learn the intricacies of designing a language.  If you're hoping to use it for anything like production, even of a hobby product, you're going to be spending way too many resources getting it to work rather than actually coding your game.  The other thing is, the widely available scripting languages will be way more robust and much faster than what you'd be able to accomplish without a large, really large effort.

Share this post


Link to post
Share on other sites
I'm going to jump on the "don't create your own language" wagon.


Yes, I realize that it's a bit ironic for me to say that, but here's my reasoning: creating a language that is rich enough to save you time is a ton of work. You also give up good debugging tools, good profiling tools, and good compiler diagnostics. In general you lose more than you gain when you roll your own. You will probably spend more time and effort maintaining your language than actually getting things done, which is kind of contrary to the purpose of using a scripting language in the first place.

Note that this primarily applies to general-purpose languages. If you want to create a highly tailored DSL for some specific task, that's one thing; but a general scripting language is almost certainly biting off more than you want to chew.

I also advocate not using a "real" syntax for DSLs, but rather something you can trivially parse with string splitting library functions, or maybe a JSON library or something similar.


TL;DR: don't do that :-P

Share this post


Link to post
Share on other sites

Oops...

 

I have done a lot already including declaring variables, calling methods, arguments, assigning variables, declaring methods...

 

I think I have done many of what I want already, I don't think I will need a large scripting language for scripting inside the game mission design, the scripting will ONLY be used in the game design, so I think the most important is using "if" statements, declaring variables, calling methods

 

But, my question is: What should I focus on my own scripting language to create something powerful for mission scripting? What are the general uses of scripting in FPS games?

 

Example of what I think of scripting:

 

If the player collided with a trigger box (invisible) then I know that the player reached some point in the game so I can do something like: onTriggerEnter event script: object1.completed();

 

For game win check scripting I could do something like:

if (objects.allCompleted)

    mission_completed();

Share this post


Link to post
Share on other sites

I wouldn't say specifically Flex/Bison. There are any number of lexer and parser generators that can be used. Many of the new-ish tools, especially those using recursive descent, combine lexer and parser generation.

 

agreed, though personally I have typically used hand-written recursive descent.

 

usually IME, the logic that comes after parsing is a lot more work than the parser itself.

 

 

my experience here (implementing/using a custom script language):

a lot of work over a lot of years, and all these years later, what I have is, at-best, mediocre...

 

though, granted, it does basically what I want out of it, so is "mostly good enough".

it does light duty scripting stuff basically ok, but isn't really solid enough to seriously consider as an implementation language.

 

 

one sad thing in life is that pretty much anything a person can do, someone else has likely already done better, so it is a choice whether to reuse what others' have done (and try to figure out ultimately what they can do for themselves, *1), or sit around and basically play catch-up.

 

what merit there is then is mostly in terms of customization or control, or aiming for unconventional use-cases (competing on unconventional metrics, ...).

 

 

*1: while pretty much everything has already been done, unless a person does something, they effectively still have nothing.

like, if a person goes and downloads some FOSS game off the internet, everything has already been written, assets created, ... but the person has, themselves, not created anything (and has no natural ownership or control over any of it).

Share this post


Link to post
Share on other sites

@ApochPiQ: I don't really need to have any debugging tools or compiler, the game is FPS and I'm planning to parse the scripts directly during the game play.

 

So, what I have is only syntax checking.

Edited by Medo3337

Share this post


Link to post
Share on other sites
It's obviously up to you, but I'd recommend against that, actually. You're in for a lot more pain than you think, unless your scripts are so bone-trivial that they may as well just be code in the first place.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!