Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local side = "back"
- local function parseColorInternal(color)
- if colors[color] or colours[color] then
- color = colors[color] or colours[color]
- elseif not (type(colors) == "number" and colors >= 0 and colors <= 65535) then
- error("Invalid colour supplied: Expected color got, "..tostring(color), 3)
- end
- return color
- end
- --# this turns on and off the colors
- local function setInternal(color, state)
- local func = state and colors.combine or colors.subtract
- rs.setBundledOutput(side, func(rs.getBundledOutput(side), color))
- end
- function allOff()
- rs.setBundledOutput(side, 0)
- end
- function allOn()
- rs.setBundledOutput(side, 65535)
- end
- --[[
- turn on the supplied colors. example usages:
- turnOn("white", colors.orange, "purple", 16)
- notice how we can use a combination of ways to say the colour, and we can also supply lots of colours and it will do it for us.
- --]]
- function turnOn(...)
- for _,color in ipairs({...}) do
- setInternal(parseColorInternal(color), true)
- end
- end
- --# Same as above only turns off the supplied colors.
- function turnOff(...)
- for _,color in ipairs({...}) do
- setInternal(parseColorInternal(color), false)
- end
- end
- function isOn(color)
- return rs.testBundledInput(side, parseColorInternal(color))
- end
- --# returns a number representing all the colours that are on
- function getOn()
- return rs.getBundledOutput(side)
- end
- --# returns a number representing all the colours that are off
- function getOff()
- return 65535 - rs.getBundledOutput(side)
- end
- function toggle(...)
- for _,color in ipairs({...}) do
- --# easier to use the internal here
- setInternal(color, not isOn(parseColorInternal(color)))
- end
- end
- function setside(s)
- side = s
- end
Advertisement
Add Comment
Please, Sign In to add comment