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

Import JSON does not work #2

Open
NesCafe62 opened this issue Jun 2, 2024 · 2 comments
Open

Import JSON does not work #2

NesCafe62 opened this issue Jun 2, 2024 · 2 comments

Comments

@NesCafe62
Copy link

Steps to reproduce:

  1. Place a spawn anywhere
  2. Press "Get room JSON" button and copy json to clipboard
  3. Reopen the planner
  4. Press "Import JSON" button and paste json, then press "Import JSON"
    Expected result: Correctly leaded structures plan
    Actual result: Nothing happens

Tested in: Firefox Debeloper Edition 123.0b6 x64
Devtools console prints this error:
Uncaught TypeError: e.split is not a function

@boldenburg
Copy link

@NesCafe62 I don't know if you're still playing Screeps, but I also encountered this bug and managed to make a quick and dirty fix. You have to modify https://github.com/admon84/screeps-room-planner/blob/main/src/components/actions/ImportFromJson.tsx as follows:

import { RoomStructuresJson } from '@/types';

change to

import { Point, RoomStructuresJson } from '@/types';

https://github.com/admon84/screeps-room-planner/blob/main/src/components/actions/ImportFromJson.tsx#L62-L68
update this function to

    Object.entries(json.structures).forEach(([structure, positions]) => {
      positions.forEach((pos) => {
        let point = pos as Point;
        let shortPoint = point.x + "-" + point.y;
        const tile = getTileForShort(shortPoint);
        addTileStructure(tile, structure);
        addStructurePosition(structure, shortPoint);
      });
    });

The bug is that the JSON import functionality assumes that the string it's parsing is in the custom shorthand notation the repo author chose to use in https://github.com/admon84/screeps-room-planner/blob/main/src/utils/constants.ts#L185.

@NesCafe62
Copy link
Author

yep, I'm still playing screeps. good that you managed to find the correct fix. though I just used online version hosted here https://screeps-room-planner.vercel.app/ maybe we could sumbit a pull request with this fix

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

2 participants