Last active
December 26, 2020 05:08
-
-
Save jacobrosenthal/59597417430680dffa456ce3449346f2 to your computer and use it in GitHub Desktop.
my unmined artifacts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remember, you have access these globals: | |
* 1. df - Just like the df object in your console. | |
* 2. ui - For interacting with the game's user interface. | |
* 3. plugin - To register the plugin, plus other helpful things. | |
* | |
* Let's log these to the console when you run your plugin! | |
*/ | |
console.log(df, ui, plugin); | |
class ArtifactsFinder { | |
planetList; | |
renderPlanets = () => { | |
this.planetList.innerHTML = ''; | |
const planets = Array.from(df.getMyPlanets()) | |
.filter(p => df.isPlanetMineable(p)) | |
.filter(p => !p.hasTriedFindingArtifact) | |
.sort((a, b) => parseInt(a.locationId, 16) - parseInt(b.locationId, 16)); | |
for (const planet of planets) { | |
if (planet.location) { | |
const planetEntry = document.createElement('div'); | |
planetEntry.addEventListener("click", () => { | |
ui.centerCoords({ x: planet.location.coords.x, y: planet.location.coords.y }); | |
}); | |
this.planetList.appendChild(planetEntry); | |
planetEntry.innerText = | |
planet.location.coords.x + | |
',' + | |
planet.location.coords.y; | |
} | |
} | |
}; | |
async render(container) { | |
container.style.width = '100px'; | |
console.log('rendered 1 artifacts finder'); | |
const findArtifactsButton = document.createElement('button'); | |
findArtifactsButton.innerText = 'find!'; | |
container.appendChild(findArtifactsButton); | |
container.appendChild(document.createElement('br')); | |
container.appendChild(document.createElement('br')); | |
findArtifactsButton.addEventListener('click', this.renderPlanets); | |
this.planetList = document.createElement('div'); | |
container.appendChild(this.planetList); | |
this.planetList.style.maxHeight = '300px'; | |
this.planetList.style.overflowX = 'hidden'; | |
this.planetList.style.overflowY = 'scroll'; | |
console.log('rendered artifacts finder'); | |
} | |
} | |
/** | |
* And don't forget to register it! | |
*/ | |
plugin.register(new ArtifactsFinder()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment