Closed Zomis closed 3 weeks ago
Thanks for the kind words.
I actually did integrate Traveler into a bot before, you can find the code here: https://github.com/exaV/screeps-kotlin The setup may be a bit outdated but it should be mostly the same today.
@exaV Thanks for the example, I did take a look at it and copied what I deemed were the relevant files and sections but it doesn't seem to work for me. I still get the "Module not found" error above.
are you uploading the module with the deploy task? it should upload a separate file. At least that's how I did it back then. I think nowadays you should be able to add is as an npm dependency in gradle and then bundle it with webpack into the same file.
Thanks, I managed to figure it out!
I added Traveler.js
and the following package.json
to a folder, e.g. <project>/ext/traveler
package.json:
{
"name": "traveler",
"version": "1.0.0",
"description": "",
"main": "Traveler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Then in build.gradle.kts
I added this:
sourceSets {
jsMain {
dependencies {
...
val pathToLocalNpmModule = rootProject.projectDir.resolve("ext/traveler").canonicalPath
implementation(npm("traveler", "file:$pathToLocalNpmModule"))
}
...
}
...
}
Then I also copied the relevant parts about Traveler from your other project.
Thanks for your great work with making it easy to get started with Screeps in my favorite language!
I have already spent (read: wasted) some time on Screeps with JavaScript, during which I added the Traveler Screeps library.
I'm struggling though with importing this into a Kotlin Screeps project.
I am getting errors such as:
When trying to add
@file:JsModule("Traveler")
and@file:JsNonModule
to the top of a separate file.