-
Notifications
You must be signed in to change notification settings - Fork 24
External Editors
You can use any editor with Oort. After creating a Rust file in Vim/VSCode/etc, right click in the Oort editor and hit "Link to a file on disk". On Chrome, this will pop up an open dialog where you can select the file. On Firefox, it will create a target for you to drag-and-drop the file onto. After this the game will re-read the file from disk every second and the built-in editor will be read-only. You can end this by selecting "Unlink from a file on disk".
To get optimal rust-analyzer diagnostics you can create a real crate. Example:
cargo new --lib myai
cd myai
cargo add oort_api
Then replace the code in src/lib.rs with the starter code for the scenario you're working on.
While the web UI only supports a single file in the editor, there are tools that can be used to combine multiple files together. This can let you work with smaller, more manageable files, and share code between AIs.
After cloning the repo, run:
cargo oort-bundler --watch -o bundled.rs path/to/a.rs path/to/b.rs
This will watch the given files for changes and write to bundled.rs
. You can then use the "Link to file on disk" option in Oort on bundled.rs
.
Using rust-sourcebundler you can bundle all files in a crate into a single rust file.
- Add rust-sourcebundler as a build dependency to your Cargo.toml:
[build-dependencies]
rustsourcebundler = { git = "https://github.com/lpenz/rust-sourcebundler", rev = "fbc017eeb3aa5c53ee5f6d15aff4d7f9d567430b" }
- Add an input file for rust-sourcebundler to read, e.g.
src/bundle_input.rs
:
extern crate myai; // this must match the package name in Cargo.toml
pub use myai::Ship;
- Add a build.rs file and add it to Cargo.toml to run rust-sourcebundler and output a bundled file:
build.rs:
use std::path::Path;
extern crate rustsourcebundler;
use rustsourcebundler::Bundler;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut bundler: Bundler =
Bundler::new(Path::new("src/bundle_input.rs"), Path::new("target/bundle_output.rs"));
bundler.crate_name("myai"); // again this must match the name in Cargo.toml
bundler.run();
Ok(())
}
Cargo.toml:
[package]
name = "myai"
build = "build.rs"
# ...
-
run
cargo build
-
Load
target/bundle_output.rs
into the Oort editor.