Advertisement
Guest User

startup

a guest
Jul 24th, 2016
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. --IC2 Reinforced Stone automation
  2. --Sand autonomous activator logic
  3.  
  4. --declare variables that persist across iterations
  5. local pulseTriggered, foamState, activatorState = false, false, false
  6.  
  7. while true do
  8.   local foamExists = rs.getInput("bottom")
  9.   local activatorEmpty = rs.getInput("back")
  10.  
  11. --check if the input from CF Turtle master changed
  12.   if foamExists ~= foamState then
  13.     pulseTriggered = false
  14.   end
  15.  
  16. --relay input to next computer
  17.   rs.setOutput("top", foamExists)
  18.  
  19. --output signal to export bus if foam in system and activator is empty
  20.   if not pulseTriggered then
  21.     rs.setOutput("left", (foamExists and activatorEmpty))
  22.     print("sand export = "..tostring((foamExists and activatorEmpty)))
  23.   end
  24.  
  25. --update variables carried to next iteration  
  26.   if (foamExists and activatorEmpty) ~= (foamState and activatorState) then
  27.     pulseTriggered = true
  28.   end
  29.  
  30.   foamState = foamExists
  31.   activatorState = activatorEmpty
  32.  
  33. --wait for redstone signal change
  34.   os.pullEvent("redstone")
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement