This is what im planning to work on next... any suggestions?

Started by
4 comments, last by evolutional 19 years, 8 months ago
Ok so ive heard about scripting an the impression that i get is that it is an external file and that it depicts: 1. Gameplay (yes/no?) 2. The Scene (yes/no?) 3. game triggers and events (yes/no?) So what i plan to do is write my own basic scripting language which will be compiled during the application setup state. This is gonna be purely for educational purposes. So supposing i only want to do those 3 types of scripts, not the pro stuff, have u got any pointers? I have ideas for how to do it so thats not a problem, has anyone tried this? Below is a rough guid to how the script will look:

<x-script>
<Scene>
	<quad>
		<texure> 	"texture.png"
		<loc>	 	~coordinates here~
		<latvel>	~lateral velocity~
		<rot>	 	~rotaion angles here~
		<rotvel>	~rotation velocity~
	<endquad>
<endscene>
<endx-script>

regards ace
Advertisement
HTML tag style is quite unusual, I think. However you could google for "script interpreter" to get the idea what you are dealing whit. You should start writing the parser first or use some free open source.
If you dont know much about scripting you could learn &#106avascript first.

You can use scripting for GUI, AI, events and basicly for anything but I wouldnt recommend scripting any render functions or heavy game logic.

Example, lets say you have AI creature and you want to handle its behaviour in script you could do something like this in c++ like script:
function TownGuard(guard){ if(!isMoving(guard))  moveToNextWaypoint(guard); thief = ThiefInRange(guard); if(thief)  attack(guard,thief);}



http://www34.brinkster.com/mpooja/work/Other/Avionics/Generic%20Script%20Engine.htm
Jesus loves you!
You could do yourself a favour with the parsing amd make it straight XML...

<x-script><scene>	<quad>		<texure>texture.png</texture>		<loc x="0" y="0" z="0" />		<latvel  x="0" y="0" z="0" />		<rot x="0" y="0" z="0" />		<rotvel x="0" y="0" z="0" />	</quad></scene></x-script>


Something like that would be a lot easier to parse as you could use tools straight out of the box, such as TinyXml.

However, you'll have a hard time getting a 'full' scripting language going with this. It's been done with Water, and to be fair to it - it's horrific... Feast your eyes on the horror:

WATER
<defmethod test_true source=required="ek_string">  <try <if> source.<execute_string/>.<not/>                <concat "Busted: "source/>.<print/>           else “OK"      </if>   >  <concat "Errored: " source/>.<print/> </try></defmethod><test_true <hairy_fn/> />


Compared to it's Java equivalent:
public void test_true (Boolean val, String source) {   if(val != true) {         System.out.println(        "Busted: " + source);    }}test_true(hairy_fn(), "hairy_fn()");


Typing it would be a nightmare, mainly because it wouldn't be as intuitive as a normal programming language.

Having said that though, I've been mocking up a system for events / actions only. The game declares a bunch of events that can be hooked and actions that could be invoked and the game then uses XML to do the declaration of hooks and dictates which actions to fire off. See this thread for more information. Note that an action can actually be triggering off a 'real' script somewhere, which is pretty neat :) It's working quite well so far and I'll publish the code once I have a demo working (I was thinking mini ASCII RPG).
There has been a bunch of messages about scripting on the gdalgo list. You should check them since the originator poster (Cavey) wants to do the same thing as you.

If you really want to create a script interpretor of your own, you should not try to do a C-like language first (because the C syntax need some kind of evoluated parser and it seems that you are not familiar with these). I suggest you to create a small lisp-like language (see the common lisp tutorial)

Basically, you could try to define very basic lisp functions (tests, arithmetic operators, and so on), then move onto function definition and so on. A complete Common Lisp interpreter is a very powerful tool and it allows very interesting programming paradigms.
I actually wrote a simple scripting language for a final project in college. It was just like a c script. Game Scripting Mastery was the book I used.
When I was finished, I had my own virtual machine which could compile and run code.
Here is a sample...
  function main(){	var x;	var y;	x = 0;	while( true )	{		if( x == 10 )			break;		else		{			print( "" + x + " " );			x = x + 1;		}		y = 0;		while( true )		{			if( y == 10 )				break;			else			{				print(y);				y = y + 1;			}		}		newline();	}}

This was my scripting language. Very good for a learning experience.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Quote:Original post by Glass_Knife
I actually wrote a simple scripting language for a final project in college. It was just like a c script. Game Scripting Mastery was the book I used.


Game Scripting Mastery is a very cool book for a beginner with an interesting in scripting and compiler writing.

This topic is closed to new replies.

Advertisement