-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insufficient documentation #108
Comments
Crate docs are available at https://docs.rs/gvas/latest/gvas/, but they might be incomplete. |
Can you create a documentation page on how to convert gvas into my own structs? Its very hard to work with the GvasFile directly and I do not understand how accessing data works. I want to make a save editor. Could you explain how to modify the data inside rust? |
Not sure what you mean by convert into your own structs, but if you wanna access and edit data you can look for examples in the |
The pub struct GvasFile {
pub deserialized_game_version: DeserializedGameVersion,
pub header: GvasHeader,
pub properties: IndexMap<String, Property>,
} |
@scottanderson The problem im facing is I dont understand how to navigate the I sent my gvasfile above for reference. |
Understanding how to navigate the properties map can be challenging due to its variability across different games. Each game may store data differently; some use simple arrays while others employ custom structs. This library accommodates these variations with a flexible structure. The structure of each property is a
The result is an object that looks like: Property::StrProperty(
StrProperty {
value: Some(String::from("Hello, world!"))
}
) Some properties are themselves also enums, especially the container types (array, map, etc.). This is primarily done to make the serde serialized output flatter, more readable and concise. If you prefer to work in JSON, you can use serde to convert a GvasFile to another format. There's also a cli wrapper for this that you may be interested in, which doesn't require you to write any code at all. See gvas2json. |
Im having problems specifically with the Struct properties and how I access things inside them or how I can serde them into my own structs. |
Hi @Swarkin, The reason I mentioned serde support is that the file that you shared earlier uses the This project focuses on serializing and de-serializing the GVAS format itself, rather than interpreting the specific game data encoded in GVAS files. For instance, Railroads Online stores different aspects of spline tracks in separate "properties": {
"SplineTrackTypeArray": { "type": "ArrayProperty", "strings": ["rail_914_h01", "rail_914_h01", "rail_914_h01"] },
"SplineTrackLocationArray": { "type": "ArrayProperty", "type_name": "Vector", "structs": [ /* Vector data */ ] },
// Other arrays...
} From the Debug trait output you attached earlier, it looks like your If you do not need to support array property values in the CustomStruct, you can coerce that use indexmap::IndexMap;
fn vec_to_indexmap(vec: Vec<(String, Property)>) -> IndexMap<String, Property> {
// This will cause data loss if the input vec contains a property array!
// See PR #102 for more information about this issue.
vec.into_iter().collect()
}
fn indexmap_to_vec(map: IndexMap<String, Property>) -> Vec<(String, Property)> {
map.into_iter().collect()
} |
Why are there no docs on how to use this crate?
Property
?ArrayProperty
?The text was updated successfully, but these errors were encountered: