Skip to content

Commit b136582

Browse files
committed
add a readme
1 parent a515d49 commit b136582

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md.html

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# input-api
2+
3+
[![go to the releases page](https://raw.githubusercontent.com/CCDirectLink/organization/master/assets/badges/releases@2x.png)](https://github.com/CCDirectLink/input-api/releases)
4+
5+
This mod allows other mods to add rebindable key bindings.
6+
7+
## Guide for modders
8+
9+
Adding your input actions is incredibly simple. Firstly, you have to define an option in `sc.OPTIONS_DEFINITION` (as you normally would) which will be written to the save file and show up in the "Controls" tab:
10+
11+
```javascript
12+
// it is recommended to do this in either `postload` or `prestart`
13+
sc.OPTIONS_DEFINITION['keys-jump'] = {
14+
type: 'CONTROLS',
15+
init: { key1: ig.KEY.CTRL, key2: undefined },
16+
cat: sc.OPTION_CATEGORY.CONTROLS,
17+
};
18+
```
19+
20+
And after that you have to add a localized label for your key binding:
21+
22+
```javascript
23+
// there are other ways to do this, but here is the simplest
24+
// you have to put this in `main`
25+
ig.lang.labels.sc.gui.options.controls.keys.jump = 'Jump';
26+
```
27+
28+
A good example of using this mod can be seen in the [Jetpack](https://github.com/CCDirectLink/CCJetpack) mod.

0 commit comments

Comments
 (0)