legion icon indicating copy to clipboard operation
legion copied to clipboard

I can not acces data to pretty print

Open laticoda opened this issue 4 years ago • 1 comments

Hello, i'm doing a game jam in which i try to use Legion to manage gold extraction.
It does work but it is ugly :

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=5760930182d0f977e51166178af0abda

i'd like to only show rounded gold stock, and to hide non useful data like phantomdata...

Here is what i tried but does'nt work

let mut query_G = <(Read<Stock_Gold>, Read<Extraction_Gold>)>::query();

        //let duo: ((std::option::Option<legion_core::borrow::RefMapMut<'_, &mut [Stock_Gold]>>),std::option::Option<legion_core::borrow::RefMapMut<'_, &mut [Extraction_Gold]>>);

        
        for chunk in query_G.iter_chunks_mut(&mut self.world) {
            
            let stock_G = chunk.components_mut::<Stock_Gold>();
            let extrac_G = chunk.components::<Extraction_Gold>();

            println!("{:?}   {:?}",stock_G,extrac_G));

https://itch.io/jam/legion-jam-rustlang

laticoda avatar Jul 21 '20 03:07 laticoda

Hello, Unless I'm missing something, this doesn't seem to be a Legion issue. What you're printing with {:?} is the Debug implementation that has been generated with #[derive(Debug)].

I think what you want to do is to actually write your own implementation of the Display trait for your Stock_Gold and Extraction_Gold types and use {} to display it.

Lisible avatar Jul 26 '20 18:07 Lisible