Advertisement
King0fGamesYami

bundledUtil

Oct 14th, 2015
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. local function testBundledOutput( side, c )
  2.     local out = rs.getBundledOutput( side )
  3.     return colors.subtract( out, c ) ~= out
  4. end
  5.  
  6. local bundled = {
  7.     setColor = function( self, c, bool )
  8.         if testBundledOutput( self.side, c ) ~= bool then
  9.             self:toggleColor( c )
  10.         end
  11.     end,
  12.     toggleColor = function( self, c )
  13.         rs.setBundledOutput( self.side, colors[ bool and "subtract" or "combine" ]( rs.getBundledOutput( self.side ), c ) )
  14.     end,
  15.     allOff = function( self )
  16.         rs.setBundledOutput( self.side, 0 )
  17.     end,
  18.     getInput = function( self, c )
  19.         if c then
  20.             return rs.testBundledInput( self.side, c )
  21.         else
  22.             local t = {}
  23.             for k, v in pairs( colors ) do
  24.                 t[ k ] = type( v ) == "number" and rs.testBundledInput( self.side, v )
  25.             end
  26.             return t
  27.         end
  28.     end,
  29. }
  30.  
  31. function getBundledSide( side )
  32.     return setmetatable( {side = side}, {__index=bundled} )
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement