JeanSummers

Factorio

Oct 21st, 2020 (edited)
1,517
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Lamp tables
  2. // Digits only
  3. // offset = 21
  4. table = `
  5. +++.+++
  6. ..+..+.
  7. +.+++.+
  8. +.++.++
  9. .+++.+.
  10. ++.+.++
  11. ++.++++
  12. +.+..+.
  13. +++++++
  14. ++++.++
  15. `
  16. // With minus sign
  17. // offset = 20
  18. tableNegative = `
  19. +++.+++
  20. ..+..+.
  21. +.+++.+
  22. +.++.++
  23. .+++.+.
  24. ++.+.++
  25. ++.++++
  26. +.+..+.
  27. +++++++
  28. ++++.++
  29. ...+...
  30. `
  31. // 3x5 display
  32. fancyTable = `
  33. +++
  34. +.+
  35. +.+
  36. +.+
  37. +++
  38.  
  39. .+.
  40. .+.
  41. .+.
  42. .+.
  43. .+.
  44.  
  45. +++
  46. ..+
  47. +++
  48. +..
  49. +++
  50.  
  51. +++
  52. ..+
  53. +++
  54. ..+
  55. +++
  56.  
  57. +.+
  58. +.+
  59. +++
  60. ..+
  61. ..+
  62.  
  63. +++
  64. +..
  65. +++
  66. ..+
  67. +++
  68.  
  69. +++
  70. +..
  71. +++
  72. +.+
  73. +++
  74.  
  75. +++
  76. ..+
  77. .+.
  78. +..
  79. +..
  80.  
  81. +++
  82. +.+
  83. +++
  84. +.+
  85. +++
  86.  
  87. +++
  88. +.+
  89. +++
  90. ..+
  91. +++
  92.  
  93. ...
  94. ...
  95. +++
  96. ...
  97. ...
  98. `
  99.  
  100. // Fancy table to normal
  101. function flat(table) {
  102.     return table.replace(/(\S)\n/g, '$1');
  103. }
  104.  
  105. function lamps(table) {
  106.     table = table
  107.         .replace(/\+/g, '1')
  108.         .replace(/\./g, '0')
  109.         .trim().split('\n')
  110.         .map(line => line.trim().split(''));
  111.     const offset = 31 - table.length;
  112.     return transpose(table)
  113.         .map(line => parseInt(line.join(''), 2) << offset);
  114. }
  115.  
  116. function transpose(arr) {
  117.     const result = [];
  118.     for (let i = 0; i < arr[0].length; i++) {
  119.         line = [];
  120.         for (let j = 0; j < arr.length; j++) {
  121.             line.push(arr[j][i]);
  122.         }
  123.         result.push(line);
  124.     }
  125.     return result;
  126. }
  127.  
  128. function oil(op = 0, cl = 0) {
  129.     let h = op *  5 + cl * 13;
  130.     let l = op *  9 + cl * 4 + (h / 20) * 15;
  131.     let p = op * 11 + cl * 2 + (l / 15) * 10;
  132.     return {
  133.         heavy: h, light: l, petroleum: p,
  134.         hoc: Math.ceil(h / 20),
  135.         loc: Math.ceil(l / 15),
  136.         steam: cl * 10,
  137.         coal:  cl * 2,
  138.         oil:   op * 20,
  139.     };
  140. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×