Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Sharing save/load tricks (DRY, WASM)

Abierto
#144 1 comentario 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
20/100
Tipo de issue
Documentación
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
rust, wasm

Línea de trabajo

Este issue comparte una implementación externa de guardado/carga de WASM en lugar de solicitar un cambio específico. Si lo exploras, empieza con la macro enlazada de rktrl_macros/src/lib.rs y su uso en src/systems/saveload.rs, y después revisa los cambios mencionados en las features de dependencias de Cargo.toml; el issue no define cómo sería la finalización.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hey @thebracket! Thank you for the amazing library and book, I'm having a blast following along. This is not so much an "issue", but rather sharing what I learned in case you want to use it in the book at some point. I'll do it tl;dr style to respect your time:

  • I've added saving / loading under WASM in https://github.com/abesto/rktrl/commit/b0da9c00125ba9bc2335f0403576b28e56c063f5. Basically it uses local storage (base64 encoded, because I GZip the saved file on the cross-platform code path).
    • FWIW, the sentence "Supporting saving via LocalStorage (a browser/JavaScript feature) is planned for a future version of RLTK." confused me for a second - RLTK doesn't explicitly support saving / loading outside the browser either, it's all serde and specs (AFAICT at least).
  • Reaching for increasingly big hammers, I managed to set up a procedural macro so that for the save / load systems there is zero repetition of the components (check out the macro and its usage). The big idea here is using the macro to split the tuple of components into chunks of at most 16, so that we can then rely on the the specs_derive-provided implementations for those.
    • I'm toying with the idea of creating a similar macro to cut down on the boilerplate involved with creating system data structs (but that's less relevant as currently the tutorial doesn't use them)
  • Getting things to compile for WASM in the first place was a bit tricky as dependencies pulled in parallel Specs features in their default-features, which trigger threading. Had to disable them in cargo.toml (see https://github.com/abesto/rktrl/commit/72a7a119385ca6ae5c6871dd31d281ba842d0ffe). I guess there might be a better way of doing this (maybe controlling whether a parallel dispatcher is used from code).

Finally, I wanted to add that I know how overwhelming input about big huge changes to writing projects can be, so wanted to explicitly say: no pressure, take these when and if they're useful. Even until then, maybe this will in itself be useful for someone else. Thank you again!

Lenguaje dominante
Rust
Estrellas
967
Forks
165
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de amethyst/rustrogueliketutorial

Todos los issues de amethyst/rustrogueliketutorial

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.