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

Class/ES6 Problem with Snowman 2 #685

Open
videlais opened this issue Aug 17, 2023 · 1 comment
Open

Class/ES6 Problem with Snowman 2 #685

videlais opened this issue Aug 17, 2023 · 1 comment
Assignees
Labels
2.X Issues for the 2.X branch

Comments

@videlais
Copy link
Owner

As reported on YouTube

"Is there any way to use ES6's classes in Snowman 2 so that I can have global custom data types? Would something like this work?"

s.object = class {
  constructor(x, y) {
    ...
  }
  ...
}

This seems to be tied to the #526 and #516 problem of how template code is handled internally. (This has been fixed in Snowman 3, but not back-ported to Snowman 2.)

@videlais videlais added the 2.X Issues for the 2.X branch label Aug 17, 2023
@videlais videlais self-assigned this Aug 17, 2023
@byronpendason
Copy link

The following worked for me, though I admittedly use a third party app (Tweezel) instead of the official Twine app so I'm not sure if it'll run on the official app.

s.Crop = class {
  constructor(type, maxAge, cost, price, season) {
    this.type = type;
    this.maxAge = maxAge;
    this.cost = cost;
    this.price = price;
    this.season = season;
  }
}

s.crops = [];
s.crops.push(new s.Crop("Potato", 6, 50, 100, "Spring"));
s.crops.push(new s.Crop("Cauliflower", 12, 80, 175, "Spring"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.X Issues for the 2.X branch
Projects
Status: In progress
Development

No branches or pull requests

2 participants