Advertisement
KelvinBouma

steamReceive.lua

Feb 24th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. modem = peripheral.wrap("left")
  2.  
  3. modem.open(1)
  4. values = {}
  5. count = 0
  6.  
  7. while true do
  8.     e, m, s, r, message = os.pullEvent("modem_message")
  9.     count = count + 1
  10.     i = 1
  11.     for word in string.gmatch(message, "[^,]+") do
  12.         if i < 2 then
  13.             i = i + 1
  14.             index = word
  15.         else
  16.             i = 1
  17.             value = tonumber(word)
  18.         end
  19.     end
  20.  
  21.     values[index] = value
  22.  
  23.     for j, k in pairs(values) do
  24.         total = 0
  25.         total = total + k
  26.     end
  27.  
  28.     if total < #values*9000 then
  29.         redstone.setOutput("top", true)
  30.     else
  31.         redstone.setOutput("top", false)
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement