Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local side = "back"
- function allOff()
- rs.setBundledOutput(side, 0)
- end
- function set(color, state)
- --# if it exists in the colors table use that colour
- if colors[color] or colours[color] then
- color = colors[color] or colours[color]
- --# if it wasn't in the table, is not a number, and is not withing the color range, error!
- elseif not (type(colors) == "number" and colors >= 0 and colors <= 65535) then
- --# level of 3 here so the finger doesn't get pointed at our functions
- error("Invalid colour supplied: Expected color got, "..tostring(color), 3)
- end
- local func = state and colors.combine or colors.subtract
- rs.setBundledOutput(side, func(rs.getBundledOutput(side), color))
- end
- --[[
- calling this `get` is a little confusing, because it's not a get, it's a test this would be a getter:
- function get()
- return rs.getBundledOutput(side)
- end
- --]]
- function get(color)
- --# if it exists in the colors table use that colour
- if colors[color] or colours[color] then
- color = colors[color] or colours[color]
- --# if it wasn't in the table, is not a number, and is not withing the color range, error!
- elseif not (type(colors) == "number" and colors >= 0 and colors <= 65535) then
- --# level of 3 here so the finger doesn't get pointed at our functions
- error("Invalid colour supplied: Expected color got, "..tostring(color), 3)
- end
- return rs.testBundledInput(side, color)
- end
- function toggle(color)
- --# we should localise variables so they cannot be accessed by other programs, also renamed function call to test, to reflect above change
- local cstate = test(color)
- --# not cstate is the same as that if else statement, except more compact... not true == false just like not false == true
- set(not cstate)
- end
- function setside(s)
- side = s
- end
Advertisement
Add Comment
Please, Sign In to add comment