FerrScript
Project DescriptionA LISP inspired scripting language that was designed to be fast, light, and compatible with the .NET Compact Framework and XNA. Written in C#.
This project is a component from my FerrEngine, originally inspired as an easy way to put scripts on mobile devices and the Xbox 360. If you're interested in contributing, feel free to contact me!
One of the major features of this project is a visual script editor component for GameMaker-like script editing. It still needs some work, but it's passable at the moment. Definitely a point for improvement in the future.
Check out the documentation!
DocumentationWishlist features
*Better script editor
*Better Performance
*Forward math parsing
Here's a quick example of what FerrScript looks like, and one way to use it:
The FerrScript file:
(x)
(y)
(xVel)
(yVel)
(texture)
(defun OnLoad
(set x (- 400.0 128.0))
(set y (- 300.0 128.0))
(set xVel -1.5)
(set yVel 0.2)
(set texture (call ~XNAFerrScriptTester.ScriptFunctions 'LoadTexture' 'firebird'))
)
(defun OnUpdate
(set x (+ x xVel))
(set y (+ y yVel))
(if (> x 800.0) (set x -256.0))
(if (> y 600.0) (set y -256.0))
(if (< x -256.0) (set x 800.0))
(if (< y -256.0) (set y 600.0))
)
(defun OnDraw
(call ~XNAFerrScriptTester.ScriptFunctions 'Draw' x y texture)
)
And the XNA class that uses it
class ScriptObjectComponent : DrawableGameComponent
{
FScript script;
public ScriptObjectComponent(Game aGame, string aScriptFileName)
:base(aGame)
{
// load and compile the script
StreamReader reader = new StreamReader(aScriptFileName);
script = FerrScriptCompiler.Inst.Compile(reader.ReadToEnd());
reader.Close();
// throw an exception if it's a bad script
if (FerrScriptCompiler.Inst.Errors.Count > 0)
{
string throwString = "";
for (int i = 0; i < FerrScriptCompiler.Inst.Errors.Count; i++)
throwString += FerrScriptCompiler.Inst.Errors[i] + "\n";
throw new Exception(throwString);
}
}
protected override void LoadContent()
{
script.CallFunction("OnLoad");
base.LoadContent();
}
public override void Update(GameTime gameTime)
{
script.CallFunction("OnUpdate");
base.Update(gameTime);
}
public override void Draw(GameTime gameTime)
{
script.CallFunction("OnDraw");
base.Draw(gameTime);
}
}
Additional information on starting a new project is available here:
Project Startup Guide.