Skip to content

RenDisco is a C# parser and runtime of a subset of RenPy.

License

Notifications You must be signed in to change notification settings

aaartrtrt/rendisco

Repository files navigation

RenDisco 🪩🕺📖

.NET

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 ✨

  • Parsing Support: Parse Ren'Py-like scripts directly from C#.
  • Execute Commands: Seamlessly execute parsed commands using a runtime engine.

Getting Started ✍️

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

Prerequisites 📦

  • .NET Core 3.1 or higher

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

See Renpy Parser via ANTLR4 for notes on updating the language grammar.

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.IRenpyParser parser = new Rendisco.AntlrRenpyParser();
Rendisco.List<Rendisco.Command> commands = parser.Parse(code);
  1. Set up the runtime engine and Play object:
Rendisco.IRuntimeEngine runtime = new ConsoleRuntimeEngine();
Play play = new Play(runtime, commands);
  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
        InputContext inputContext = new InputContext(userChoice - 1);
        play.Step(inputContext: inputContext);
    }
    else
    {
        Console.WriteLine("-");
        play.Step();
    }
}

License 📝

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

Acknowledgments

About

RenDisco is a C# parser and runtime of a subset of RenPy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published