Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ACCEPTABLE_COLORS = {
- colors.white,
- colors.orange,
- colors.magenta,
- colors.lightBlue,
- colors.yellow,
- colors.lime,
- colors.pink,
- colors.gray,
- colors.lightGray,
- colors.cyan,
- colors.purple,
- colors.blue,
- colors.brown,
- colors.green,
- colors.red,
- colors.black
- }
- local expect = require("cc.expect")
- local exp, field, range = expect.expect, expect.field, expect.range
- function printColor(text, color)
- exp(1, text, "string")
- exp(1, color, "number")
- for index, value in ipairs(ACCEPTABLE_COLORS) do
- if (color == value) then break end
- if (color ~= value and index == #ACCEPTABLE_COLORS) then
- print(text)
- end
- end
- term.setTextColor(color)
- print(text)
- term.setTextColor(colors.white)
- end
- function writeColor(text, color)
- exp(1, text, "string")
- exp(1, color, "number")
- for index, value in ipairs(ACCEPTABLE_COLORS) do
- if (color == value) then break end
- if (color ~= value and index == #ACCEPTABLE_COLORS) then
- write(text)
- end
- end
- term.setTextColor(color)
- write(text)
- term.setTextColor(colors.white)
- end
- return { printColor = printColor, writeColor = writeColor }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement