Personal library?


I find myself doing a lot of copy and paste between previous levels and the new level. ISTM that developing a library of functions (and eventually classes or, ideally, patches against existing classes) is a big part of the game, however there doesn’t seem to be any support for such a library. Am I missing something here?


I keep a personal code list of all the code that I write and another document of the functions I use regularly.

But as far as an ability to create your own code library I think it might have been talked about before. I think I remember something about a note pad or an ability to save your code to the profile like a library being suggested, I just can’t seem to locate the forum post at the moment.


I’d imagine that it would be an excellent thing to introduce in the middle of the game, and could be handled as a tab on the code editing window: main and lib, where the first thing main would contain (in python anyway) would be something like

from lib import *

No idea what the javascript equivalent is (but then, properly learning js is why I’m playing).

The rationale is pretty clear: encourage users to actually write and maintain a code library. It would also be an excellent way to demonstrate code-rot over library changes.


Its an HTML tag

<script src=""></script>


I use a tool called Rollup to use ES modules for code bundling and managing utilities, though it requires coding outside of the browser.

For example I have some utilities:

// Array.js
// ...
export function maximumBy (fn, arr) { /* ... */ }
export function minimumBy (fn, arr) { /* ... */ }
// ...
// levels.js
import {maximumBy} from '../utils/Array'
const chooseTarget = maximumBy(enemy => hero.distanceTo(enemy))

I then run rollup on the level file, which includes any imported modules into my code that I can paste into CodeCombat. It is somewhat of an inconvenience however.

Other discussions:


Here is another post talking about adding code snippits.