Sign in to follow this  
dave

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

Recommended Posts

dave    2187
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

Share this post


Link to post
Share on other sites
GCoda    100
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 javascript 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

Share this post


Link to post
Share on other sites
evolutional    1393
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Glass_Knife    8636
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.

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