Closed bedryck closed 9 months ago
Hi @bedryck, thanks for the feedback - we could perhaps implement this as an instance method, e.g.: room.state.players:to_message()
I'm afraid returning the clean structure directly is not going to be possible due to how the de-serialization works internally.
It will be very useful for me, also it will be helpful in debugging as well. Let me know if you do something like that. I think I'll solve my problem using a singleton for now. Thank you for your reply!
Thanks @bedryck, I've just released 0.15.7 adding a :to_raw()
method on all schema instances. 🙌
This now outputs more easily-readable output:
pprint(room.state.players:to_raw())
You are amazing. I just tested and it is exactly what I need! Thank you a lot!
It's not a bug, I am in the process of learning Colyseus. One thing with which I have a problem now is that
room.state
has a lot of additional internal data. Example: If I call -pprint(self.room.state.players)
I get:What I need. I want to get pure state example:
pprint(self.room.state.players)
Why I need it. I have a room controller that sends messages to needed components and in one case I need to send
room.state.players
, but such as room.state.players have functions I get error thatmsg.post
in Defold cannot send data.I think I can avoid this error just iterating by
room.state.players
and accumulating data which I need, and then send data throughmsg.post
Or I can use singleton where I save instances of room and then from component get state from singleton without using
msg.post
But maybe I missed something and there is a way to get a pure state. Thank you!