Losetta 0.10.5
dotnet add package Losetta --version 0.10.5
NuGet\Install-Package Losetta -Version 0.10.5
<PackageReference Include="Losetta" Version="0.10.5" />
paket add Losetta --version 0.10.5
#r "nuget: Losetta, 0.10.5"
// Install Losetta as a Cake Addin #addin nuget:?package=Losetta&version=0.10.5 // Install Losetta as a Cake Tool #tool nuget:?package=Losetta&version=0.10.5
Losetta
English | Japanese |
---|
AliceScript is a scripting language callable and customizable from C# and other CLR languages. Losetta is the official language processor for AliceScript and is compatible with AliceScript and AliceSister.
Losetta is published under the MIT License and can be used in proprietary and free/open source applications. Losetta is based on CSCS.
See LICENCE for more information.
How to use
Initialization
From NuGet, install both Losetta and the Losetta.Runtime package in your project.
Applications that load AliceScript must initialize their APIs before running AliceScript. To initialize all APIs available in Alice.Runtime, write
AliceScript.Runtime.Init();
Some applications may want to use only the basic AliceScript functions (if
and print
). To initialize only the basic API, write as follows
AliceScript.Runtime.InitBasicAPI();
It is also possible to initialize by namespace. For example, if you want to initialize only the file processing API after initializing the basic API, write
AliceScript.NameSpaces.Alice_IO.Initer();
Execute
To execute a script, use the methods of the Alice
class in the AliceScript
namespace.
To execute a script in string form, call Alice.Execute
. Here is an example
var result = Alice.Execute("1+2");
Console.WriteLine(result);//εΊε:3
To execute a script from a file, call Alice.ExecuteFile
. Here is an example
var result = Alice.ExecuteFile("myScript.txt");
The return value of the Execute
and ExecuteFile
methods is a Variable
class, representing some value in AliceScript; you can convert this to use the value result in C# code or use a generic method. For example, the following example calculates 2+3
in AliceScript and stores it in a C# int
type.
int result = Alice.Execute<int>("2+3");
Usage for Custom Functions
In AliceScript, you can bind a C# function as is if it has only one function overload. The following example defines an AliceScript namespace called MyFunctions
and a Pow
method that returns a number squared when a single number is entered into it.
[AliceNameSpace]
public static class MyFunctions
{
public static double Pow(double x)
{
return x * x;
}
}
In order to actually call the defined namespace and functions from AliceScript, a bind registration is required. The following example registers MyFunctions
defined earlier.
Alice.RegisterFunctions<MyFunctions>();
Another way to define custom functions in AliceScript is to define a class that extends the FunctionBase
class.
The following example shows how to define a MyFunction
function that has one argument and returns the first argument when called.
public class MyFunction : FunctionBase
{
public MyFunction()
{
//The name of this function
this.Name = "MyFunction";
//Minimum number of arguments required to call this function
this.MinimumArgCounts = 1;
this.Run += MyFunction_Run;
}
private void MyFunction_Run(object sender, FunctionBaseEventArgs e)
{
//Statement to be executed when the function is called
e.Return = e.Args[0];
}
}
In order to actually call the defined function from AliceScript, it must be registered. In the following example, register MyFunction
defined earlier.
FunctionBaseManerger.Add(new MyFunction());
Available APIs can be found in the API browser.
For detailed usage instructions, please refer to AliceScriptDocs (Japanese). For those seeking information on earlier versions, AliceScriptWiki may be useful.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- System.Text.Encoding.CodePages (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Losetta:
Package | Downloads |
---|---|
Losetta.Runtime
Package of basic functions and APIs available in AliceScript |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.10.5 | 146 | 3/28/2024 |
0.10.4 | 204 | 12/31/2023 |
0.10.2 | 150 | 12/23/2023 |
0.10.1 | 155 | 12/10/2023 |
0.9.24 | 174 | 9/10/2023 |
0.9.23 | 140 | 9/3/2023 |
0.9.22 | 162 | 8/27/2023 |
0.9.21 | 165 | 8/11/2023 |
0.9.20 | 251 | 3/18/2023 |
0.9.19 | 255 | 3/5/2023 |
0.9.18 | 303 | 2/13/2023 |
0.9.17 | 338 | 1/28/2023 |
0.9.16 | 354 | 1/19/2023 |
0.9.15 | 350 | 1/8/2023 |
0.9.13 | 359 | 1/2/2023 |
0.9.11 | 345 | 12/27/2022 |
0.9.10 | 330 | 12/18/2022 |