Advertisement
LatvianModder

Bundled API

Jun 24th, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. local side = "back"
  2. local bundle = {}
  3. local instaUpdate = false;
  4.  
  5. function init(s)
  6.   side = s
  7.   rs.setBundledOutput(side, 0)
  8. end
  9.  
  10. function add(id, col)
  11.   bundle[id] = {}
  12.   bundle[id]["col"] = col
  13.   bundle[id]["on"] = false
  14. end
  15.  
  16. function setInstantUpdate(b)
  17.   instaUpdate = b
  18. end
  19.  
  20. function set(id, b)
  21.   bundle[id]["on"] = b
  22.   if instaUpdate then
  23.     update()
  24.   end
  25. end
  26.  
  27. function get(id)
  28.   return bundle[id]["on"]
  29. end
  30.  
  31. function update()
  32.   val = 0
  33.   for id, data in pairs(bundle) do
  34.     if data["on"] then
  35.       val = val + data["col"]
  36.     end
  37.   end
  38.   rs.setBundledOutput(side, val)
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement