new.mp4
The menu is openable with ;
by default
Move through command history with ↑
arrows ↓
See alias list
- Executing from the CLI
- Types
- Examples - Simplest
- TypeScript support
- JavaScript support
- Contribution
- Building
Include the mod as a hard dependency in ccmod.json
or use:
if (window.vim) {
... your aliases ...
}
For example:
vim.executeString('title-screen')
vim.executeString('load-preset: 0')
interface Alias {
origin: string /* namespace */
name: string /* command name */
description: string
command: (...args: string[]) => void /* command to execute */
condition: /* if the alias appears in the menu, updated every time the menu is shown */
| 'ingame' /* can only be used in-game */
| 'global' /* can be used anywhere */
| 'titlemenu' /* can only be used in the title menu */
| ((ingame: boolean) => boolean) /* custom function */
arguments: AliasArguemnt[] /* see below, argument length is not enforced */
keys: string[] /* what do include in the fuzzy search */
display: string[] /* what to display */
}
interface AliasArguemnt {
type: string /* value type, doesnt really do anything, not enforced */
possibleArguments?: /* possible types, not enforced */
AliasArguemntEntry[] /* hard-coded values */ | (() => AliasArguemntEntry[]) /* custom function, run every time the possible values list is shown */
description: string
}
interface AliasArguemntEntry {
value: string /* what will be passed to the function */
keys: string[] /* what do include in the fuzzy search */
display: string[] /* what to display */
}
// namespace command-name description condition function
vim.addAlias('cc-vim', 'reload', 'Reload the game, 'global', () => { window.location.reload() })
vim.addAlias(
'cc-vim',
'player-move',
'Move player',
'ingame',
(x?: string, y?: string, z?: string) => {
const pos: Vec3 = ig.game.playerEntity.coll.pos
ig.game.playerEntity.setPos(
pos.x + parseInt(x ?? '0'),
pos.y + parseInt(y ?? '0'), pos.z + parseInt(z ?? '0')
)
},
[
{ type: 'number', description: 'x to add' },
{ type: 'number', description: 'y to add' },
{ type: 'number', description: 'z to add' },
]
)
vim.addAlias(
'cc-vim',
'load-preset',
'Load save preset',
'global',
(presetId: string) => {
const id = parseInt(presetId.trim())
console.log('presetId:', id)
},
[{
type: 'number',
possibleArguments(): AliasArguemntEntry[] {
const arr: AliasArguemntEntry[] = []
for (const i of Object.keys(sc.savePreset.slots)) {
const slot: sc.SavePresetData = sc.savePreset.slots[parseInt(i)]
const value = i.toString()
const keys = [value, slot.title.value, slot.sub.value, slot.path]
arr.push({ value, keys, display: keys })
}
return arr
},
description: 'Preset to load',
}]
)
npm install --save-dev github:krypciak/cc-vim
import type * as _ from 'cc-vim'
you dummy learn typescript
the same as typescript just remove the types (thingis behind :
)
Feel free to pr any aliases you would like to see added
git clone https://github.com/krypciak/cc-vim
cd cc-vim
pnpm install
pnpm run start
# this should return no errors or very few
npx tsc