Advertisement
TokMor

Factorio State Machine

Apr 18th, 2022
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. timer A
  2. //inputs:
  3. //signal_red : inverted number of stations still building BPs
  4. //signal_N : Number of grids above and below the center line should be built
  5.  
  6. //BP Book Pages:
  7. //1: Grid Segment
  8. //2: Horizontal Stub Station
  9. //3: Vertical Stub Station Top
  10. //4: Vertical Stub Station Bottom
  11. //5: Reset next column signal
  12. 10: //Initialize and enumerate all variables used
  13. X = 0 // horizontal offset for building BP
  14. Y = 0 // vertical offset for building BP
  15. W = 0 // width of deconstruction area
  16. H = 0 // height of deconstruction area
  17. I = 0 // current tile horizontal postion
  18. J = 0 // current tile vertical position
  19. C = 0 // contruct/deconstruct signal, map to construction_robot
  20. B = 60 * 5 //standard wait time, 5 seconds
  21. G = 256 // Size of grid
  22. => 30
  23. 30: //Wait until N combinator is turned on
  24. N > 0 => 40
  25. 40: //Build initial stub station
  26. reset A
  27. C = 2
  28. => 50
  29. 50: //Wait standard wait time
  30. A > B => 60
  31. 60: //Turn off BP
  32. C = 0
  33. reset A
  34. => 70
  35. 70: //Wait standard wait time
  36. A > B => 80
  37. 80: //Build Main block
  38. reset A
  39. X = G * I
  40. X = X + 1
  41. Y = G * J
  42. C = 1
  43. => 90
  44. 90: //Wait standard wait time
  45. A > B => 100
  46. 100:
  47. C = 0
  48. reset A
  49. => 110
  50. 110: //Wait standard wait time
  51. A > B => 120
  52. 120: //Build Stub Station
  53. reset A
  54. C = 2
  55. => 130
  56. 130: //Wait standard wait time
  57. A > B => 140
  58. 140: //Turn off BP
  59. C = 0
  60. reset A
  61. I == 0 => 150
  62. I != 0 => 250
  63. 150: //Build vertical stub stations
  64. J >= 0 => 160
  65. J < 0 => 210
  66. 160: //Build vertical stub station up
  67. C = 3
  68. reset A
  69. =>170
  70. 170: //Wait
  71. A > B => 180
  72. 180: //Turn off BP
  73. C = 0
  74. reset A
  75. => 190
  76. 190: //Wait
  77. A > B => 200
  78. 200: //Handle middle row
  79. J == 0 => 210
  80. J > 0 => 250
  81. 210: //Build vertical stub station down
  82. C = 4
  83. reset A
  84. =>220
  85. 220: //Wait
  86. A > B => 230
  87. 230: //Turn off BP
  88. C = 0
  89. reset A
  90. => 240
  91. 240: //Wait
  92. A > B => 250
  93. 250: //Select next cell
  94. J == 0 => 260
  95. J > 0 => 270
  96. J < 0 => 280
  97. 260:
  98. J = 1
  99. => 290
  100. 270:
  101. J = J * -1
  102. => 290
  103. 280:
  104. J = J * -1
  105. J = J + 1
  106. =>290
  107. 290: //Check if done
  108. J <= N => 80
  109. => 300
  110. 300: //Turn off N circuit
  111. X = 5
  112. Y = -20
  113. C = 5
  114. reset A
  115. => 310
  116. 310: //Wait
  117. A > B => 320
  118. 320: //Turn off BP
  119. C = 0
  120. reset A
  121. => 330
  122. 330: //Wait
  123. A > B => 340
  124. 340: //Wait until N signal turned back on
  125. N > 0 => 80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement