How mrcatplay/blockbot works
Project type and purpose
• This is a Node.js-based code generator for CtrlBots scripting.
File structure
• index.js – the entry point that pulls everything together.
• function/
• event/ – modules modeling each type of event node (Window.js, death.js, end.js, eventlist.js, message.js).
• variable/ – EditVariable.js handles “cloud” variable nodes.
• package.json / package-lock.json – Node.js dependencies and scripts.
README for additional insights
• The README describes the domain (CtrlBots events, commands, variables) and how users create scripts by placing blocks.
a. Main components
1. Input Layer
– index.js CLI or import
2. Graph Parsing Layer
– searchInDrawioFile.js: reads and locates all nodes
– findConnections.js: identifies edges between nodes
3. Graph Traversal & Interpretation
– dfs.js: depth-first traversal of the node graph
– handleConnectionAction.js: triggers appropriate node handlers as edges are followed
4. Node Handlers
– eventMessager.js: maps event nodes to bot-script event calls
– variables.js & EditVariable.js: manage variable definition, operations, and injection into script
– function/event/*.js: specific event modules (Window, death, end, etc.)
5. Output Generation
– index.js collects processed nodes and writes final CtrlBots script (or JSON)
6. Execution Environment
– CtrlBots engine that will run the generated script in the game
b. Relationships and interactions
• Parsing Layer produces a node+edge representation passed to the Traversal & Interpretation.
• During traversal, each node is dispatched to a handler (event or variable).
• Handlers emit fragments of bot‐script.
• Output Generator stitches those fragments into a complete script.
c. Architectural patterns / design principles
• Modular handlers: each node type (event, variable) has its own module.
• Separation of concerns: parsing vs. traversal vs. code‐generation.
• Graph‐based processing: explicit DFS over node graph.
• Pluggable: new event/command types can be added by dropping a new handler in function/event or function/variable.
d. Key technologies
• Node.js for orchestration.
• XML parsing (built-in or via a library you include in searchInDrawioFile.js).
• Plain-JS modules for each block type.
Detailed capture of essential architecture
• For each layer, break out its sub-components (e.g., under “Node Handlers” show eventMessager.js, variables.js, EditVariable.js, each event/*.js).
• Modular addition point: “Drop new .js in function/event or function/variable to extend”.