Advertisement
natie3

newElevator

Oct 17th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. os.loadAPI("radarAPI.lua")
  2. on = {}
  3.  
  4. function calculate(player)
  5.   local num = math.pow(2, math.floor((player.y - 2) / 11))
  6.   add(num)
  7. end
  8.  
  9. function add(number)
  10.   --print("add " .. number)
  11.   local cur = redstone.getBundledOutput("right")
  12.   if not colors.test(cur, number) then
  13.     redstone.setBundledOutput("right", cur + number)
  14.   end
  15.  
  16.   on["" .. number] = 5
  17. end
  18.  
  19. function remove(number)
  20.   --print("remove" .. number)
  21.   local cur = redstone.getBundledOutput("right")
  22.   if colors.test(cur, number) then
  23.     redstone.setBundledOutput("right", cur - number)
  24.   end
  25. end
  26.  
  27. function check()
  28.   for k, v in pairs(on) do
  29.     -- print(k .. ": " .. v)
  30.     if v == 0 then
  31.       remove(tonumber(k))
  32.     else
  33.       on[k] = on[k] - 1
  34.     end
  35.   end
  36. end
  37.  
  38. radarAPI.init("bottom", 0.1, nil, check)
  39. radarAPI.addArea(-1, 0, 2, 117, 0, 0, calculate)
  40. --radarAPI.addArea(-1, 0, 13, 18, 0, 0, function() add(2) end)
  41. --radarAPI.addArea(-1, 0, 24, 29, 0, 0, function() add(4) end)
  42. --radarAPI.addArea(-1, 0, 35, 40, 0, 0, function() add(8) end)
  43. --radarAPI.addArea(-1, 0, 46, 51, 0, 0, function() add(16) end)
  44. --radarAPI.addArea(-1, 0, 57, 62, 0, 0, function() add(64) end)
  45. --radarAPI.addArea(-1, 0, 68, 73, 0, 0, function() add(128) end)
  46. radarAPI.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement