Fast text formatting language for C#. This is a .NET port of starscript by MeteorDevelopment, written in Java. Licensed under MIT.
- Lightweight; No dependencies. Just .NET 10.
- Standard operators: + - * / % ^
- Ability to call functions defined in C#
- Variables can be different each time they are used
- Conditional output (ternary operator)
- Variables can be maps
Hello {name}!Number: {someNumber * 100}FPS: {round(fps)}Today is a {good ? 'good' : 'bad'} dayName: {user.name}
You can find the latest version number at the top of this README. With that:
Your .csproj:
<PackageReferenceInclude="Starscript.Net"Version="{version}" />In your code:
usingStarscript;// Parseif(!Parser.TryParse(@"Hello {name}! Starscript was originally created by {originalAuthor()}",outParser.Resultresult)){foreach(varerrorinresult.Errors)Console.WriteLine(error);return;}// CompileScriptscript=Compiler.SingleCompile(result);// The compiler also has the ability to batch compile and directly compile from source (throwing a ParseException if any errors are present)// Create Starscript hypervisor instanceStarscriptHypervisorhv=StarscriptHypervisor.Create().WithStandardLibrary();// Adds the default functions, not requiredhv.Set("name",()=>"GreemDev");// dynamic variablehv.Set("originalAuthor", _ =>"MineGame159");// function// RunConsole.WriteLine(hv.Run(script));// or...Console.WriteLine(script.Execute(hv));