Kaynağa Gözat

Implement h, m, and s

Added the three time instructions.
ApisNecros 1 yıl önce
ebeveyn
işleme
920c544409
2 değiştirilmiş dosya ile 16 ekleme ve 6 silme
  1. 5 3
      examples.txt
  2. 11 3
      starfish.js

+ 5 - 3
examples.txt

@@ -21,8 +21,10 @@ c22g\           prints "5011012", or what should be read as "50", "110", and "12
 \nnn;
   2
 
-f:&&1+nn;       prints "1615"
+f:&&1+nn;       	prints "1615"
 
-abcdefr&r3[D&n; prints "10"
+abcdefr&r3[D&n; 	prints "10"
 
-10772**01p;     prints nothing, but after running cb.box should have two rows, and [1][0] == 'b'
+10772**01p;     	prints nothing, but after running cb.box should have two rows, and [1][0] == 'b'
+
+s":"m":"hnonon;		prints whatever your current time is

+ 11 - 3
starfish.js

@@ -77,6 +77,13 @@ class CodeBox {
          * @type {int}
          */
         this.curr_stack = 0;
+        /**
+         * The current date
+         * 
+         * This value is updated every tick
+         * @type {?Date}
+         */
+        this.datetime = null;
 
         this.codeBoxDOM = document.getElementById(codeBoxID);
         if(!this.codeBoxDOM) {
@@ -356,13 +363,13 @@ class CodeBox {
                     // TODO
                     break;
                 case "h":
-                    // TODO
+                    this.stacks[this.curr_stack].Push(this.datetime.getUTCHours());
                     break;
                 case "m":
-                    // TODO
+                    this.stacks[this.curr_stack].Push(this.datetime.getUTCMinutes());
                     break;
                 case "s":
-                    // TODO
+                    this.stacks[this.curr_stack].Push(this.datetime.getUTCSeconds());
                     break;
                 // Code box manipulation
                 case "g":
@@ -389,6 +396,7 @@ class CodeBox {
 
     Swim() {
         const instruction = this.box[this.pointer.Y][this.pointer.X];
+        this.datetime = new Date();
 
         if(this.stringMode != 0 && dec(instruction) != this.stringMode) {
             this.stacks[this.curr_stack].Push(dec(instruction));