SHARE
TWEET

Untitled

a guest Jun 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sleep(2)
  2.  
  3. side = "left"
  4. deviceName = "ic2bug"
  5. energySaveMode = false
  6.  
  7. term.clear()
  8. rednet.open(side)
  9. rednet.broadcast("LOGIN " .. deviceName)
  10. print("Gerät " .. deviceName .. " angemeldet.")
  11.  
  12. function starts_with(str, start)
  13.  return string.sub(str,1,string.len(start))==start
  14. end
  15.  
  16. function enableEnergySaveMode()
  17. end
  18.  
  19. function disableEnergySaveMode()
  20. end
  21.  
  22. function enableGlobalEnergySaveMode()
  23.  enableEnergySaveMode()
  24.  energySaveMode = true
  25.  rednet.broadcast("ENERGYSAVEMODEON " .. deviceName)
  26. end
  27.  
  28. function disableGlobalEnergySaveMode()
  29.  disableEnergySaveMode()
  30.  energySaveMode = false
  31.  rednet.broadcast("ENERGYSAVEMODEOFF " .. deviceName)
  32. end
  33.  
  34. function receiveAskedParameter(key, value)
  35. end
  36.  
  37. function system_shutdown()
  38. end
  39.  
  40. function system_reboot()
  41. end
  42.  
  43. function setParameter(key, value)
  44.  rednet.broadcast("PARSET " .. deviceName .. " " .. key .. " " .. value)
  45. end
  46.  
  47. function callParameter(key)
  48.  rednet.broadcast("CALL " .. deviceName .. " " .. key)
  49. end
  50.  
  51. while true do
  52.  id, message = rednet.receive()
  53.  
  54.  if starts_with(message, "ENERGYSAVEMODEON") then
  55.   if energySaveMode == false then
  56.    enableEnergySaveMode()
  57.   end
  58.  
  59.   energySaveMode = true
  60.  end
  61.  
  62.  if starts_with(message, "ENERGYSAVEMODEOFF") then
  63.   if energySaveMode == true then
  64.    disableEnergySaveMode()
  65.   end
  66.  
  67.   energySaveMode = false
  68.  end
  69.  
  70.  if message == "SYSTEMREBOOT" then
  71.   system_reboot()
  72.   reboot()
  73.  end
  74.  
  75.  if message == "SYSTEMSHUTDOWN" then
  76.   system_shutdown()
  77.   shutdown()
  78.  end
  79.  
  80.  if starts_with(message, "PARSEND") then
  81.   result = {}
  82.   for word in message:gmatch("%w+") do table.insert(result, word) end
  83.  
  84.   if result[2] == deviceName then
  85.    receiveAskedParameter(result[3], result[4])
  86.   end
  87.  end
  88. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top