Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. Estournet
    Estournet

    Estournet

    @Estournet

    Chat Follow Unfollow
    1
    Reputation
    2
    Posts
    1175
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • 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 •
    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 •