Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom action example not complete #177

Open
lab101 opened this issue Mar 12, 2024 · 1 comment
Open

Custom action example not complete #177

lab101 opened this issue Mar 12, 2024 · 1 comment

Comments

@lab101
Copy link

lab101 commented Mar 12, 2024

I had some issues making a custom action.
When you use the code from the example in the documentation there's a promise error after the apply.

There should be return Promise.resolve (); in the apply in order to make the example work.

@makemefeelgr8
Copy link

Well, the engine seems to be long dead. I've managed to make my custom actions work, though.

In case someone finds this issue, the real custom action example should be more like:

class MyAction extends Monogatari.Action {

    static matchString ([action]) {
        return action === 'myaction';
    }

    constructor ([myaction, ...args]) {
        super ();
    }
    
    async apply() {
  
    }

    async revert() {
  
    }

    async didApply() {
      return { advance: true };
    }

    async didRevert() {
      return { advance: true, step: true };
    }
}

MyAction.id = 'MyAction';

Yes, you do need the didApply and didRevert boilerplate, or rewind won't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants