aaartrtrt / rendisco

RenDisco is a C# parser and runtime of a subset of RenPy.
MIT License
2 stars 1 forks source link

RenDisco πŸͺ©πŸ•ΊπŸ“–

RenDisco is a project for .NET to parse and execute scripts written in a subset of Ren'Py - the popular engine for creating visual novels. It allows the integration of Ren'Py-like scripts within C# applications, allowing access to the .NET ecosystem while utilising the easy-to-learn syntax of Ren'Py to create dialogue.

Features ✨

Getting Started ✍️

To get started with RenDisco, clone this repository and build the solution in your preferred .NET environment.

Prerequisites πŸ“¦

Installation πŸ”§

  1. Clone the repository:
    git clone https://github.com/aaartrtrt/RenDisco.git
  2. Navigate to the cloned directory and build the project:
    cd RenDisco
    dotnet build

Usage πŸ—οΈ

Below is a simple example of how to use RenPySharp in your project:

  1. Import RenDisco:
using RenDisco;
  1. Prepare your script: Write your Ren'Py script as a string or load it from a file.
string script = @"
label start:
    e ""Hello, world!""
    jump finish

label finish:
    e ""Goodbye, world!""
    return
";
  1. Parse the script:
RenDisco.RenpyParser parser = new RenDisco.RenpyParser();
List<RenDisco.RenpyCommand> commands = parser.Parse(script);
  1. Set up the runtime engine:
RenDisco.IRuntimeEngine runtime = new RenDisco.SimpleRuntimeEngine();
  1. Do a Step loop:
while (true)
{
    // Check if we need to read a choice from the user
    if (play.WaitingForInput)
    {
        Console.Write("> ");
        int.TryParse(Console.ReadLine(), out int userChoice);

        // Create a StepContext with the user's choice loaded
        StepContext stepContext = new StepContext(userChoice - 1);
        play.Step(stepContext: stepContext);
    }
    else
    {
        Console.WriteLine("-");
        play.Step();
    }
}

License πŸ“

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments