-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Here you will find out how you can utilize RIFT in your projects.
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.
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.
Now that you know what this can do, you can go and look and usage documentation:
Last edit: 25.10.2024