Yare-Rust
A library for making bots for yare with Rust.
How it works
You make a Rust library and compile to wasm. Then you use the wasm2yareio script to generate a JavaScript yare bot. The result can be copied into the game.
Setup
You will need Rust, and some additional tools.
Create a new Rust library.
Put this in your Cargo.toml.
[]
= ["cdylib"]
[]
= "0.1.1"
[]
= "s"
= true
Then copy wasm2yareio.js from the linked submodule into your project and
install a dependency. Make sure your Node is up-to-date.
Example
This is an example bot. You need to define an external function called tick
that has one parameter. This will be called every tick.
pub extern "C"
You should make safe wrappers for these function so that you don't have to have unsafe blocks in your bot code.
For example, you could do something like this:
use CString;
use spirit;
use player;
/// Your own Spirit struct with all the information you want.
/// Parse all spirits into your own Spirit structs.
// No unsafe block needed here!
pub extern "C"
Check out this template for an example of how you can structure your code!
Building
To build your yare bot, you first need to compile to wasm. Use this:
Then you want to pass it through wasm2yareio.
It is also recommended that you install the tampermonkey script to automatically upload your code to yare.io: Click to install.