Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: room.drops[resourceType] is not iterable #205

Open
xyzzy529 opened this issue Apr 23, 2022 · 1 comment
Open

TypeError: room.drops[resourceType] is not iterable #205

xyzzy529 opened this issue Apr 23, 2022 · 1 comment

Comments

@xyzzy529
Copy link

Issue summary

Installed fresh 0.5.2.1 and received below error

Description of issue:

The room was stuck not harvesting or upgrading.
https://screeps.com/a/#!/room/shard0/W12S22

I re-copied the 0.5.2.1 release and it gave error.

Steps to reproduce:

AFAIK, just copy/paste the 0.5.2.1 version into main and commit it in screeps/scripts. Then error appears.
The room was previously built out.

Error message:

[11:21:45 AM][shard0]drops: 0 [ruin (link) #626426ae1fdb0a4b034f6fae]
[11:21:45 AM][shard0]TypeError: room.drops[resourceType] is not iterable
    at Overseer.registerLogisticsRequests (main:23745:44)
    at Overseer.init (main:23952:18)
    at _Overmind.init (main:24061:6199)
    at main (main:24313:14)
    at Object.wrap (main:969:16)
    at Object.loop (main:24322:21)
    at __mainLoop:1:52
    at __mainLoop:2:3
    at Object.exports.evalCode (<runtime>:15845:76)
    registerLogisticsRequests(colony) {
        // Register logistics requests for all dropped resources and tombstones
        for (let room of colony.rooms) {
            // Pick up all nontrivial dropped resources
            for (let resourceType in room.drops) {
                console.log("drops:", resourceType, room.drops[resourceType]);  // <--- Added for Debug
                for (let drop of room.drops[resourceType]) {                                 // <--- throws error
                    if (drop.amount > LogisticsNetwork.settings.droppedEnergyThreshold
                        || drop.resourceType != RESOURCE_ENERGY) {
                        colony.logisticsNetwork.requestOutput(drop);
                    }
                }
            }
        }

Suggested fix (optional):

unknown

Other information:

‣ Version: Overmind v0.5.2
‣ Checksum: 0x2bf8f766f8e
‣ Assimilated: No (clearance code: null) [WIP]
‣ Operating mode: automatic

@xyzzy529
Copy link
Author

Here is what seems to work as a fix:

    registerLogisticsRequests(colony) {
        // Register logistics requests for all dropped resources and tombstones
        for (let room of colony.rooms) {
            // Pick up all nontrivial dropped resources
            console.log("drops ALL:", JSON.stringify(room.drops,null,4) );
            for (let dropIdx in room.drops) {                      // <--- Added new level of room.drops
                for (let resourceType in room.drops[dropIdx]) {
                    try {
                        for (let drop of room.drops[dropIdx][resourceType]) {
                            if (drop.amount > LogisticsNetwork.settings.droppedEnergyThreshold
                                || drop.resourceType != RESOURCE_ENERGY) {
                                colony.logisticsNetwork.requestOutput(drop);
                                console.log("process drop: ", JSON.stringify(drop.pos), drop.amount );
                            }
                        }
                    } catch (error) { 
                        console.log("drops-error:", dropIdx, resourceType, error);
                    }
                }
            }
        }
        // Place a logistics request directive for every tombstone with non-empty store that isn't on a container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant