Advertisement
Guest User

treefarm.lua

a guest
Jun 3rd, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. vos.loadApi('apis.lua')
  2.  
  3. Peripheral.wrap({ type = 'wireless_modem' })
  4. Relay.find()
  5.  
  6. local active = false
  7.  
  8. --[[
  9. local me = vos.loadApi('me.api')
  10.  
  11. while true do
  12.   local count = me.getItemCount(13384, 0)
  13.   print(count)
  14.  
  15.   local enabled = count < 2048
  16.  
  17.   print('setting output to ' ..
  18.     tostring(not enabled))  
  19.   rs.setOutput('right', not enabled)
  20.   os.sleep(30)
  21. end
  22. --]]
  23.  
  24. Message.addHandler('tankInfo', function(h, id, msg)
  25.   local tank = msg.contents
  26.   active = tank.amount / tank.capacity * 100 < 90
  27.   print('setting output to ' .. tostring(not active))
  28.   rs.setOutput('right', not active)
  29. end)
  30.  
  31. Event.addHandler('heartbeat', function()
  32.   Relay.send('getTankInfo', {
  33.     name = 'Ethanol'
  34.   })
  35. end)
  36.  
  37. Event.heartbeat(30)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement