瀏覽代碼

Add input/output options

Added options to the computer to determine how I/O is handled. These are
unused at this time, but will be needed in the future.
ApisNecros 1 年之前
父節點
當前提交
ea75382c19
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      IntComp/Computer.js

+ 4 - 0
IntComp/Computer.js

@@ -15,6 +15,8 @@ module.exports = class Computer {
      * @param {Object} options Options that can be enabled within the computer
      * @param {boolean} options.followPointer When true, the memory will be dumped every call to Execute with the current instruction highlighted
      * @param {number} options.tickRate The number of milliseconds between calls to Execute. Initializes to 0.
+     * @param {boolean} options.inputFromConsole When true, the computer will prompt for input on the console. If false, it will check for an linked computer and, if one exists, will wait for input from that computer.
+     * @param {boolean} options.outputToConsole When true, the computer will print the output of opcode 4 to the console. If false, it will check for an linked computer and, if one exists, pass the output to that computer.
      */
     constructor(stack, options = {}) {
         this._initialMemory = DeepClone(stack);
@@ -49,6 +51,8 @@ module.exports = class Computer {
         this.options = {
             followPointer: options.followPointer ?? false,
             tickRate: options.tickRate ?? 0,
+            inputFromConsole: options.inputFromConsole ?? false,
+            outputToConsole: options.outputToConsole ?? false,
         };
     }