Skip to content

Commit

Permalink
Merge pull request #3 from dmitmel/master
Browse files Browse the repository at this point in the history
change metadata, fix ccloader v3 compatibility and reduce code duplication
  • Loading branch information
prismskey authored Mar 17, 2021
2 parents 8fda615 + 53f6b72 commit c21b9a7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 46 deletions.
36 changes: 0 additions & 36 deletions mod.js

This file was deleted.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "Character Swap",
"version": "1.0.0",
"description": "Play as a variety of characters previously unavailable.",
"plugin": "mod.js",
"module": false,
"ccmodDependencies": {
"crosscode": "^1.2.0",
"ccloader": "^2.14.3"
}
}
"name": "character-swap",
"ccmodHumanName": "Character Swap",
"version": "1.0.0",
"description": "Play as a variety of characters previously unavailable",
"module": true,
"plugin": "plugin.js",
"ccmodDependencies": {
"crosscode": "^1.2.0"
}
}
39 changes: 39 additions & 0 deletions plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export default class CharSwapMod {
prestart() {
this.keymap = new Map([
['Lea', ig.KEY.T],
['Emilie', ig.KEY.Y],
['Glasses', ig.KEY.U],
['Schneider', ig.KEY.I],
['Apollo', ig.KEY.O],
['Joern', ig.KEY.P],
['Shizuka', ig.KEY.G],
['Hlin', ig.KEY.H],
['Grumpy', ig.KEY.J],
['Buggy', ig.KEY.K],
['Sergey', ig.KEY.L],
['Triblader1', ig.KEY.N],
]);
}

main() {
ig.input.bind(ig.KEY.ALT, 'swap_char');
for (const name of sc.PARTY_OPTIONS) {
const binding = this.keymap.get(name);
if (binding != null) ig.input.bind(binding, `swap_${name}`);
}

ig.game.addons.preUpdate.push(this);
}

onPreUpdate() {
if (!ig.input.state('swap_char')) return;

for (const name of this.keymap.keys()) {
if (ig.input.pressed(`swap_${name}`)) {
sc.model.player.setConfig(sc.party.models[name].config);
break;
}
}
}
}

0 comments on commit c21b9a7

Please sign in to comment.