Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. Estournet
Estournet

Estournet

@Estournet

Chat Follow Unfollow
1
Reputation
2
Posts
1.1k
Profile views
0
Followers
0
Following
Joined 17 Apr 2020, 21:12 Last Online 21 Apr 2020, 09:31

  • Profile
  • More
    • Continue chat with Estournet
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups
Estournet Follow

Posts made by Estournet

RE: When running server: "TypeError: Cannot read property 'types' of undefined"

Hi @endel

Okay I figured out how to do. I had this trouble and I am using plain JS, which adds more trouble :p (and I hadn't read the documentation about State, I have to admit)
So, if anyone has the same trouble, here is a solution for plain Javascript :

import { Room } from "colyseus";
// Imports need to be done with require for Schema
const schema = require('@colyseus/schema');
const { defineTypes, Schema } = schema;

export class TestState extends Schema {
  foo = "bar";
  anything = "you want"
}

export class TestRoom extends Room {
  onCreate(options) {
    this.setState(new TestState());
  }
}

// This is the important part
defineTypes(TestState, {
  whatever: "string"
});

Thanks for the help !

posted in Questions & Help • 17 Apr 2020, 22:13
RE: When running server: "TypeError: Cannot read property 'types' of undefined"

@boygiandi Could you paste some code please, I'm having the same trouble but I can't fix it with your method :/

posted in Questions & Help • 17 Apr 2020, 21:36

© 2023 Endel Dreyer