Skip to content
Oleksandr Nemesh edited this page Oct 25, 2024 · 5 revisions

Welcome to RIFT docs

Here you will find out how you can utilize RIFT in your projects.

About

This library was made for use with Eclipse Menu, but it can be used anywhere you want. The basic idea was to provide users with a way to create custom status messages displayed in-game, that could show anything the user wanted.

This library differs from normal string formatting libraries by incorporating a full-fledged interpreter, which not only allows you to replace simple things by keywords, but also perform various calculations all in the format string itself. RIFT supports arithmetics, string manipulation, boolean math and conditional logic.

Example

Here's a simple example of what RIFT can do:

#include <rift.hpp>

int main() {
    // Parse the script and generate the AST
    auto script = rift::compile(R"(A({a}) + B({b}) = {a + b}\n)").unwrap(); // note: don't use unwrap for user input

    // Output: "A(1) + B(2) = 3"
    std::cout << script->run({
        {"a", rift::Value::from(1)},
        {"b", rift::Value::from(2)}
    });

    // We can also use the script multiple times
    // Output: "A(3) + B(4) = 7"
    std::cout << script->run({
        {"a", rift::Value::from(3)},
        {"b", rift::Value::from(4)}
    });
    
    delete script; // don't forget to delete the script after you're done with it
    return 0;
}

As you can see, all we have to do is parse the script string and then we can provide it with values.

Contents

Now that you know what this can do, you can go and look and usage documentation:

  1. Including in your project
  2. Immediate vs Precompiled
  3. rift::Value

Last edit: 25.10.2024

Clone this wiki locally