Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicYoshiMaster committed Mar 17, 2022
0 parents commit 1dec9cd
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cc-speedrun-utilities
CrossCode mod containing various utilities and features for speedrunning and debugging the game.
48 changes: 48 additions & 0 deletions Utilities/freeSP.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* CrossCode Speedrun Utilities - freeSP.js
*
* Hotkey for giving SP, gives points past the regular cap.
*/

sc.OPTIONS_DEFINITION["keys-free-sp"] = {
type: "CONTROLS",
init: {
key1: ig.KEY.U,
key2: undefined
},
cat: sc.OPTION_CATEGORY.CONTROLS,
hasDivider: true,
header: "cc-speedrun-utilities",
};

let giveSPAmount = 12;

/**
* @inject
* Detect when Save and Load Position/Map binds are pressed
*/
sc.Control.inject({
freeSPPress: function () {
return ig.input.pressed("free-sp");
}
});

/**
* @inject
* Handle execution of Save and Load Position/Map keybinds
*/
ig.ENTITY.Player.inject({
gatherInput(...args) {
if (ig.game.isControlBlocked()) {
return this.parent(...args);
}

if (!ig.interact.isBlocked()) {
if (sc.control.freeSPPress()) {
this.params.currentSp += giveSPAmount;
}
}

return this.parent(...args);
}
});
91 changes: 91 additions & 0 deletions Utilities/saveHotkeys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* CrossCode Speedrun Utilities - saveHotkeys.js
*
* Hotkeys for loading your latest autosave and making quicksaves
* for quickly practicing segments repeatedly
*/

sc.OPTIONS_DEFINITION["keys-autosave-load"] = {
type: "CONTROLS",
init: {
key1: ig.KEY.I,
key2: undefined
},
cat: sc.OPTION_CATEGORY.CONTROLS,
hasDivider: false,
header: "cc-speedrun-utilities",
};

sc.OPTIONS_DEFINITION["keys-quick-save"] = {
type: "CONTROLS",
init: {
key1: ig.KEY.O,
key2: undefined
},
cat: sc.OPTION_CATEGORY.CONTROLS,
hasDivider: false,
header: "cc-speedrun-utilities",
};

sc.OPTIONS_DEFINITION["keys-quick-load"] = {
type: "CONTROLS",
init: {
key1: ig.KEY.P,
key2: undefined
},
cat: sc.OPTION_CATEGORY.CONTROLS,
hasDivider: false,
header: "cc-speedrun-utilities",
};

let currQuickSave = null;

/**
* @inject
* Inject hotkeys.
*/
sc.Control.inject({
autosaveLoadPress: function () {
return ig.input.pressed("autosave-load");
},

quickSavePress: function() {
return ig.input.pressed("quick-save");
},

quickLoadPress: function() {
return ig.input.pressed("quick-load");
}
});

/**
* @inject
* Handle execution of hotkeys.
*/
ig.ENTITY.Player.inject({
gatherInput(...args) {
if (ig.game.isControlBlocked()) {
return this.parent(...args);
}

if (!ig.interact.isBlocked()) {
if (sc.control.autosaveLoadPress()) {
ig.storage.loadSlot(-1);
}

if (sc.control.quickSavePress()) {
currQuickSave = {};
ig.storage._saveState(currQuickSave);
currQuickSave = new ig.SaveSlot(currQuickSave);
}

if (sc.control.quickLoadPress()) {
if(currQuickSave) {
ig.storage.loadSlot(currQuickSave);
}
}
}

return this.parent(...args);
}
});
18 changes: 18 additions & 0 deletions assets/data/lang/sc/gui.en_US.json.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"labels": {
"options": {
"headers": {
"cc-speedrun-utilities": "Speedrun Utilities"
},

"controls": {
"keys": {
"free-sp": "Give SP",
"autosave-load": "Load Autosave",
"quick-save": "Quick Save",
"quick-load": "Quick Load"
}
}
}
}
}
14 changes: 14 additions & 0 deletions ccmod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "yoshi-speedrun-utilities",
"version": "1.0.0",
"module": true,
"title": "Speedrun Utilities",
"description": "Various useful features for speedrunning and debugging.",
"prestart": "prestart.js",
"dependencies": {
"input-api": "^1.0.0"
},
"icons": {
"24": "icon.png"
}
}
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions prestart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* CrossCode Speedrun Utilities
*
* A growing collection of useful features for speedrunning and debugging the game.
*/

import './Utilities/freeSP.js'
import './Utilities/saveHotkeys.js'

0 comments on commit 1dec9cd

Please sign in to comment.