amethyst / rustrogueliketutorial

Roguelike Tutorial in Rust - using RLTK
MIT License
905 stars 156 forks source link

Ch8 Items - ConvertSaveload in WantsToDropItem component #174

Open dgobi opened 3 years ago

dgobi commented 3 years ago

Hello, I'm a beginner following along with the tutorial and I came across a derivation that seems to be incorrect:

#[derive(Component, Debug, ConvertSaveload, Clone)]
pub struct WantsToDropItem {
    pub item : Entity
}

From another closed issue it seems like the ConvertSaveload is an error? Either that or I'm missing something important. No matter how I change things in the includes I get errors about being unable to find 'serde' in the list of imported crates.

Frans-Lukas commented 3 years ago

Chapter 10 goes through how ConvertSaveload is used. I also saw that it's written before being used (i.e. in ch. 8). If you want to fix the error import use specs::saveload::{ConvertSaveload, Marker};

I also needed to use a specific version of serde for it to work, here's what I put in my cargo.toml:

serde = { version = "^1.0.44", features = ["derive"] }
serde_json = "^1.0.44"
andreas-wolf commented 2 years ago

And don't forget to add specs = { version = "0.18.0", features = ["serde"] } to cargo.toml. I was missing the features part and got unresolved import specs::saveload which I did not see at first because you're flooded with cannot determine resolution for the derive macro ConvertSaveload errors. This change is silently introduced in the sources chapter 11 (2.10 Saving and Loading).