darkforest-eth / plugins

A showcase of Dark Forest plugins from the community!
https://plugins.zkga.me
GNU General Public License v3.0
123 stars 136 forks source link

[remote-explore] fire event when chunks are mined #203

Closed modukon closed 9 months ago

modukon commented 2 years ago

Makes the remote explorer fire events as soon as a chunk is mined. This works the same way as the default web miner. If you listen to the event it will be fired when either of them mines a chunk.

If you want to test this, run the miner and enter this into the console:

function testMine(chunk, time) {
    console.log(time+" chunk", chunk);
}
df.minerManager.on("DiscoveredNewChunk", testMine);

Here is the code that fires the event in the default client: https://github.com/darkforest-eth/client/blob/93e24f18d64ae506687e4e3a6e798ee46e84b286/src/Backend/Miner/MinerManager.ts#L156

I don't know much about how events work, if I did something wrong pls correct me.

EDIT: i accidentally closed this pr and had to make a new one, sorry

harryhare commented 2 years ago

hi, the game code seems changed which lead to the plugin failed to open.

modukon commented 2 years ago

This plugin exists as embedded plugin here: https://github.com/darkforest-eth/client/blob/master/embedded_plugins/Remote-Explorer.ts

The embedded plugin was made compatible but this version here was not and no longer works, would it not be better to only have one version of this plugin? Could we delete this version and make PRs to the embedded version? Or why are there 2 versions of the same plugin?