Pandafuchs

Shutdown Energy on Overflow

Dec 16th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. prox = sensor.wrap("right")
  3.  
  4. function print_r ( t )
  5.     local print_r_cache={}
  6.     local function sub_print_r(t,indent)
  7.         if (print_r_cache[tostring(t)]) then
  8.             print(indent.."*"..tostring(t))
  9.         else
  10.             print_r_cache[tostring(t)]=true
  11.             if (type(t)=="table") then
  12.                 for pos,val in pairs(t) do
  13.                     if (type(val)=="table") then
  14.                         print(indent.."["..pos.."] => "..tostring(t).." {")
  15.                         sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
  16.                         print(indent..string.rep(" ",string.len(pos)+6).."}")
  17.                     else
  18.                         print(indent.."["..pos.."] => "..tostring(val))
  19.                     end
  20.                 end
  21.             else
  22.                 print(indent..tostring(t))
  23.             end
  24.         end
  25.     end
  26.     sub_print_r(t,"  ")
  27. end
  28.  
  29. while (true) do
  30.     details = prox.getTargetDetails("4,-1,0")
  31.     if (details["StoredPercentage"] > 75) then
  32.         print("Energyzufur wird abgeschaltet...")
  33.         redstone.setOutput("left", true)
  34.     elseif (details["StoredPercentage"] < 50) then
  35.         print("Energyzufur wird eingeschaltet..." .. details["StoredPercentage"])
  36.         redstone.setOutput("left", false)
  37.     end
  38.     os.sleep(5)
  39. end
Add Comment
Please, Sign In to add comment