4个版本 (2个破坏性更新)
| 0.3.1 | 2019年11月2日 | 
|---|---|
| 0.3.0 | 2019年11月2日 | 
| 0.2.0 | 2019年8月5日 | 
| 0.1.0 | 2019年7月25日 | 
#102 in #save
14KB
279 代码行数(不包括注释)
libsts
libsts是一个用于处理《Slay the Spire》存档和运行文件的Rust库。
安装
将以下内容添加到您的 Cargo.toml
[dependencies]
libsts = "0.3"
基本用法
use libsts::{Save, SaveError};
use std::fs;
fn main() {
    // Load the Ironclad save file
    let contents = fs::read_to_string("IRONCLAD.autosave").unwrap();
    
    // Attempt to parse the save file
    if let Ok(mut save) = Save::new(&contents) {
        // Increase the player's hand size and gold
        save.hand_size += 2;
        save.gold += 999;
        
        // Get the base64 string representation of our modified savefile
        if let Ok(modified_save) = save.to_b64_string() {
            // Attempt to overwrite the current save file
            // with our modified cheaty save file
            fs::write("IRONCLAD.autosave", modified_save); 
        }
        
        // Or if you're using the BETA branch of STS:
        if let Ok(modified_save) = save.to_string() {
            // ...
            fs::write("IRONCLAD.autosaveBETA", modified_save);
        }
    }
}
许可证
根据您选择,许可协议为
- Apache许可证版本2.0 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT 或 https://open-source.org.cn/licenses/MIT)
依赖项
~1.1–1.9MB
~40K SLoC