Documentation for Colyseus.
This project uses Markdown for documentation which is compiled with mkdocs.
pip install -r requirements.txt
mkdocs serve
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs lucidsightinc/mkdocs-material
Documentation for Colyseus
Home Page: https://docs.colyseus.io
follow the docs:
docs/docs/state/schema-callbacks.md
Lines 326 to 334 in aefbf8f
the codegen/parser
dose not support wildcard yet:
Reported by dambien on Discord:
So I'm seeing this "When using arrays, it's important to use the ArraySchema type. Do not use plain arrays."
Does this apply to all arrays in general? I'm using a temporary array in the middle of a function, should I be converting that over to an arrayschema?
(Requested by @Alaadel)
[Documentation typo]
docs/docs/state/schema.zh_CN.md
Lines 1221 to 1227 in b718261
Shouldn't it be :
inventory.items.set("left", new Weapon());
inventory.items.set("right", new Shield());
instead of:
inventory.set("left", new Weapon());
inventory.set("right", new Shield());
Hi There,
I've been reading up the documentation recently (https://docs.colyseus.io/best-practices/)
and came across the best-practices part where it is recommended to adopt the Command-Pattern.
In the example given in the docs for "OnJoinCommand.ts" file,
// OnJoinCommand.ts
import { Command } from "@colyseus/command";
import { MyRoom } from './MyRoom'; // this is missing in the example.
export class OnJoinCommand extends Command<MyRoom, {
sessionId: string
}> {
execute({ sessionId }) {
this.state.players[sessionId] = new Player();
}
}
and below is the code given
For MyRoom.ts file:
import { Room } from "colyseus";
import { Dispatcher } from "@colyseus/command";
import { OnJoinCommand } from "./OnJoinCommand";
class MyRoom extends Room<YourState> {
dispatcher = new Dispatcher(this);
onCreate() {
this.setState(new YourState());
}
onJoin(client, options) {
this.dispatcher.dispatch(new OnJoinCommand(), {
sessionId: client.sessionId
});
}
onDispose() {
this.dispatcher.stop();
}
}
MyRoom imports OnJoinCommand , and vice-versa.
It seems the circular-dependency issue is introduced due to the decision of having generic type Room for class Command (Command)
I saw in previous versions of colyseus docs, instead of taking reference of a room, you could pass reference to the room state instead (see: https://0-13-x.docs.colyseus.io/best-practices/command-pattern/)
Which seems like a better way as it would avoid this sort of circular dependency issue when splitting commands into different module.
But I'm not sure why that approach has been changed (?) now. If you could help suggest some way to avoid this issue ?
https://docs.colyseus.io/best-practices/command-pattern/
> Why?
Models (@colyseus/schema) should contain only data, without game logic.
Rooms should have as little code as possible, and forward actions to other structures
The 'Why' section does not sufficiently explain to me why I should care about this. I see no issue with my schema containing game logic, as you have not told me why that is a bad thing. I also haven't been convinced that rooms should have as little code as possible. Why? Is the code all sent to and from the clients in every patch update? That seems impossible, and easy to fix deeper in the code.
Given no real justification for why to bother with the command pattern, and no real examples showing how it improves code cleanliness, this recommendation just seems like an opinionated way to structure your code.
If these are just Colyseus best practices, they should be better justified to the people the documentation is asking to do extra work. If these are meant to be "Accepted and understood best practices for Typescript in General", please link to external documentation supporting and further explaining the concepts.
FWIW I believe that I want the command pattern, and that I should bother with it eventually, but I've read this doc five times now and am still fighting with myself over what benefit I'm getting from it. Trying to implement it from the start has just confused my Colyseus adoption. I recommend either expanding this doc to better explain the reasoning, and then give better examples. OR to remove this doc from 'best practices' and put it in a more specific 'code cleanliness / Command Pattern' section until it is complete enough to not confuse new users.
The example here https://github.com/colyseus/docs/blob/master/docs/server/room.md#example-room doesn't build with Typescript. The error I get is
Argument of type '{ map: typeof Player; }' is not assignable to parameter of type 'DefinitionType'
which occurs on the line
@type({ map: Player})
I'm not sure if this is required but I can fix this by changing the Player
class definition to extend Schema
:
export class Player extends Schema {
x: number = 0.11;
y: number = 2.22;
}
Reference link: https://docs.colyseus.io/colyseus/demo/starboss
Comments: Works in Edge.
Errors:
TODO
Need to document this limitation
(Requested by @Alaadel)
Suggested by @Eeveeboo on Discord:
The documentation should have a visual overview of the system. A visual flow showing the server, client, schema lifecycle.
In the doc only typescript format is given.
How about it in javascript?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.