MZ Lines won't draw on my scene :(

I'm trying to draw lines between nodes on a map. I'm not sure why, but I can't get the lines to show. Can someone tell me what I'm doing wrong? Neither me nor chat gpt can diagnose the issue. [Edit: this code was *not* generated by ChatGPT. I just use it as a helper when I get stuck because while the code it makes is generally useless, it does sometimes catch human errors that I overlook. It's suggestions never work, but at least it points out what I mistyped or where I threw in a circular reference.]
The code works as such:
JavaScript:
    calculateNodeConnections() {
        for (const nodeID in Pockets.LTS.nodesList) {
            const node = Pockets.LTS.nodesList[nodeID];
            if (node && node.unlocked) {
                for (const connectedNodeID of node.connectedNodes) {
                    const connectedNode = Pockets.LTS.nodesList[connectedNodeID];
                    if (connectedNode && connectedNode.unlocked) {
                        const key = `${node.nodeID}-${connectedNodeID}`;
                        const reverseKey = `${connectedNodeID}-${node.nodeID}`;

                        // Check if the connection or its reverse already exists
                        if (!this._nodeConnections[key] && !this._nodeConnections[reverseKey]) {
                            const line = new PIXI.Graphics();
                            this.addChild(line);
                            line.lineStyle(20, 0xFFFFFF, 1); // Change line style as needed
                            line.moveTo(node.xCoord, node.yCoord);
                            line.lineTo(connectedNode.xCoord, connectedNode.yCoord);
                            line._zIndex = 9999;
                            this._nodeConnections[key] = line;
                        }
                    }
                }
            }
        }
    }
I've verified in console that the Coords are all valid, alpha is at 1, zIndex is impossibly high, and it's included in the scene
1693453203913.png

And the LTS_Node that appears in the list of children on the Scene *IS* being displayed. Can anyone tell me what's going wrong here and how I fix it? I just want to draw some lines connecting some clickable sprites 🙁
Chat GPT is not a reliable method of creating plugins, and most of the developers on the forums here who answer code-related questions have expressed that they will not help with code generated by Chat GPT.
Chat GPT is not a reliable method of creating plugins, and most of the developers on the forums here who answer code-related questions have expressed that they will not help with code generated by Chat GPT.
This code wasn't generated by ChatGPT. I use it as an assistance tool when I get exasperated. The code it creates is useless, but helps me figure out what's missing in my own code sometimes.
Pro tip: ChatGPT is a cool helper, but it's got the coding skills of a first year student :/

Edit: it makes a wonderful rubber duck tho.
Is what you posted the entirety of your code?
CT_Bolt made a plugin for drawing lines between events or coordinates
Post in thread 'Draw line from event to event?' https://forums.rpgmakerweb.com/index.php?threads/draw-line-from-event-to-event.155192/post-1331612
No. there's a bunch going on in the background.

This is the bulk of it
JSON:
class Window_OMGPMenu extends Window_Command {
    constructor(rect) {
        super(rect)
    }
    makeCommandList() {
        this.addCommand("Travel", "travel");
        this.addCommand("Menu", "menu");
        this.addCommand("Cancel", "cancel");
    }
}

class Window_OMGPBackground extends Window_Scrollable {
    constructor(rect) {
        super(rect)
        this._travelMap = Pockets.LTS.backgroundImage;
        this._travelRect = rect;
    }
    drawBackground() {
        this.contents.blt(this._travelMap, this._travelRect.x, this._travelRect.y, this._travelRect.width + this.padding, this._travelRect.height,0, 0, this._travelRect.width, this._travelRect.height);
    }

}

class Window_OMGPNodes extends Window_Base {
    constructor() {
        super()
    }
}

// scene

class Scene_PocketsTravelSystem extends Scene_Base {
    constructor() {
        super();
        this.createWindowLayer();
        this._windowLayer.x = 0;
        this._windowLayer.y = 0;
        this.createBackgroundWindow();
        this.createMenuWindow();
        this.createNodes();
        this._playerNode = null;
        this._selectedNode = null;
        this._nodeConnections = [];
    }

    createMenuWindow() {
        const rect = this.menuWindowRect();
        this._menuWindow = new Window_OMGPMenu(rect);
        this._menuWindow.setHandler("travel", this.commandTravel.bind(this));
        this._menuWindow.setHandler("menu", this.commandMenu.bind(this));
        this._menuWindow.setHandler("cancel", this.popScene.bind(this));
        this.addWindow(this._menuWindow);
    }

    createBackgroundWindow() {
        const rect = this.backgroundWindowRect()
        this._backgroundWindow = new Window_OMGPBackground(rect);
        this._backgroundWindow.frameVisible = false;
        this._backgroundWindow.margin = 0;
        this._backgroundWindow.padding = 0;
        this._backgroundWindow.drawBackground();
        this.addWindow(this._backgroundWindow)
    }

    createNodes() {
        initializeNodeData();
        for (const nodeID in Pockets.LTS.nodesList) {
            if (Pockets.LTS.nodesList.hasOwnProperty(nodeID)) {
                const nodeInfo = Pockets.LTS.nodesList[nodeID];
                const node = new LTS_Node(nodeInfo);
                node.setupClickHandler();
                this.addChild(node);
            }
        }
    }

    calculateNodeConnections() {
        for (const nodeID in Pockets.LTS.nodesList) {
            const node = Pockets.LTS.nodesList[nodeID];
            if (node && node.unlocked) {
                for (const connectedNodeID of node.connectedNodes) {
                    const connectedNode = Pockets.LTS.nodesList[connectedNodeID];
                    if (connectedNode && connectedNode.unlocked) {
                        const key = `${node.nodeID}-${connectedNodeID}`;
                        const reverseKey = `${connectedNodeID}-${node.nodeID}`;

                        // Check if the connection or its reverse already exists
                        if (!this._nodeConnections[key] && !this._nodeConnections[reverseKey]) {
                            const line = new PIXI.Graphics();
                            line.lineStyle(20, 0xFFFFFF, 1); // Change line style as needed
                            line.moveTo(node.xCoord, node.yCoord);
                            line.lineTo(connectedNode.xCoord, connectedNode.yCoord);
                            line._zIndex = 9999;
                            this.addChild(line);
                            this.update();
                            this._nodeConnections[key] = line;
                        }
                    }
                }
            }
        }
    }


    menuWindowRect() {
        const ww = this.mainCommandWidth();
        const wh = this.calcWindowHeight(3, true);
        const wx = Graphics.boxWidth - this.mainCommandWidth();
        const wy = 4;
        return new Rectangle(wx, wy, ww, wh);
    }

    backgroundWindowRect() {
        const ww = Graphics._width + $gameSystem.windowPadding() *2;
        const wh = Graphics._height+ $gameSystem.windowPadding() *2;
        const wx = 0;
        const wy = 0;
        return new Rectangle(wx, wy, ww, wh);
    }

    commandTravel() {
        this._menuWindow.activate();
        this.calculateNodeConnections();
    }


    commandMenu() {
        SceneManager.push(Scene_Menu);
    }

    setPlayerNode(nodeId) {
        this._playerNode = Pockets.LTS.nodesList[nodeId]
    }
}

class LTS_Node extends Sprite_Clickable {
    constructor(nodeInfo) {
        super();
        this._nodeInfo = nodeInfo;
        this.bitmap = ImageManager.loadPicture(this._nodeInfo.nodeImage);

        this.x = this._nodeInfo.xCoord;
        this.y = this._nodeInfo.yCoord;
    }

Code:
function initializeNodeData() {
    // populate node list on first run
    const isDataInitialized = localStorage.getItem('pocketsLtsInitialized')
    if (!isDataInitialized || isObjectEmpty(Pockets.LTS.nodesList)) {
        const travelNodeData = JSON.parse(Pockets.LTS.parameters.mapNodes);
        const travelNodes = {};
        let hasUpdates = false;

        for (const nodeData of travelNodeData) {
            let nodeDataParsed = JSON.parse(nodeData)
            const newNode = {
                nodeID: nodeDataParsed.nodeID,
                xCoord: nodeDataParsed.xCoord,
                yCoord: nodeDataParsed.yCoord,
                firstTimeEvent: nodeDataParsed.firstTimeEvent,
                anyTimeEvent: nodeDataParsed.anyTimeEvent,
                nodeImage: nodeDataParsed.nodeImage,
                connectedNodes: JSON.parse(nodeDataParsed.connectedNodes),

                // Add more properties as needed, excluding 'unlocked' and 'visited'
            };

            // Preserve 'unlocked' and 'visited' properties from the existing node, if it exists
            if (Pockets.LTS.nodesList[nodeDataParsed.nodeID]) {
                newNode.unlocked = Pockets.LTS.nodesList[nodeDataParsed.nodeID].unlocked;
                newNode.visited = Pockets.LTS.nodesList[nodeDataParsed.nodeID].visited;
            }
            else {
                newNode.unlocked = nodeDataParsed.unlocked
                newNode.visited = nodeDataParsed.visited
            }

            travelNodes[nodeDataParsed.nodeID] = newNode;

        }
        if (isObjectEmpty(Pockets.LTS.nodesList)) {
            Pockets.LTS.nodesList = travelNodes;
        }

        // Check if there are updates to the node list
        for (const nodeID in travelNodes) {
            if (travelNodes.hasOwnProperty(nodeID)) {
                const newNode = travelNodes[nodeID];
                const oldNode = Pockets.LTS.nodesList[nodeID];

                if (!oldNode || !isObjectEqual(newNode, oldNode)) {
                    hasUpdates = true;
                    break;
                }
            }
        }

        if (!isObjectEmpty(travelNodes) && hasUpdates) {
            Pockets.LTS.nodesList = travelNodes;
        }
        localStorage.setItem('pocketsLtsInitialized', 'true');
    }

}
I am going to have to do *SO MUCH* refactoring when I get this working.
CT_Bolt made a plugin for drawing lines between events or coordinates
Post in thread 'Draw line from event to event?' https://forums.rpgmakerweb.com/index.php?threads/draw-line-from-event-to-event.155192/post-1331612
I was looking at that example, but I'm not within the $gameScreen I don't think, and I'm not working with events. I'm working within a scene.
1693454731221.png

Those two odd circles are LTS_Nodes that were successfully drawn. I just want to add a system to visually show the paths on the graph.
@Kenen, @AquaEcho Okay - if anyone ends up coming here to find a similar solution:
The way to draw lines using PIXI.JS is as such:


JavaScript:
if (!this._nodeConnections[key] && !this._nodeConnections[reverseKey]) {
                            const line = new PIXI.Graphics();
                            line.lineStyle(10, 0xFFFFFF, 1)
                                .position.set(node.xCoord, node.yCoord)
                            line.lineTo(connectedNode.xCoord - node.xCoord, connectedNode.yCoord - node.yCoord)

                            this.addChild(line);
                            this._nodeConnections[key] = line;

You can't use Pixi.Graphics().moveTo without first defining a starting position using .position.set(). I have no idea why, and at this point I'm too scared to ask. This has some other hiccups that I haven't figured out yet, including how to set the Z order (for now, I am just relying on having things drawn in order and praying there are convenient ways to wipe and redraw everything.
  1. graphics = new PIXI.Graphics()
  2. graphics.lineStyle(lineWidthInPixels, colorCode, alpha0to1)
  3. graphics.position.set(xStart, yStart)
  4. graphics.lineTo(xDifference, yDifference)
  5. YourScene.addChild(graphics)

    1693796973731.png

Original thread: https://forums.rpgmakerweb.com/threads/lines-wont-draw-on-my-scene.160777/