Importing external libraries



  • Hi,

    I am learning JavaScript for this game and I would like to import an external library like "http://numericjs.com/numeric/index.php" (code at http://numericjs.com/numeric/lib/numeric-1.2.6.js).

    What is the best way to do it in screeps ?

    And importing libraries like this one is it something consuming lot of ressources in a screeps game ?


  • Culture

    You can use the library by copying the file into your `screeps` code directory and then using `require` to load it.

    Downsides to using more code (whether it's yours or an external library)-

    1. You have a 2mb limit on how much source code you can have.
    2. When you `require` a library that isn't in the require cache you have to pay for all the parsing times.

    Basically you should be fine using smaller libraries, but should avoid the larger ones.