Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function printf(...)
- --[[
- Author: Wassil Janssen a.k.a. Creator
- ]]--
- local clrs = {
- ["0"] = colors.white,
- ["1"] = colors.orange,
- ["2"] = colors.magenta,
- ["3"] = colors.lightBlue,
- ["4"] = colors.yellow,
- ["5"] = colors.lime,
- ["6"] = colors.pink,
- ["7"] = colors.gray,
- ["8"] = colors.lightGray,
- ["9"] = colors.cyan,
- ["a"] = colors.purple,
- ["b"] = colors.blue,
- ["c"] = colors.brown,
- ["d"] = colors.green,
- ["e"] = colors.red,
- ["f"] = colors.black,
- }
- local prefixes = {
- ["+"] = term.setTextColor,
- ["-"] = term.setBackgroundColor,
- }
- local str = ""
- for i,v in pairs({...}) do
- str = str.." "..tostring(v)
- end
- local pos = 1
- local toPrint = ""
- while true do
- local skip = 0
- local char = str:sub(pos,pos)
- if char == "\027" then
- term.write(toPrint)
- toPrint = ""
- local n = str:sub(pos+1,pos+1)
- local nn = str:sub(pos+2,pos+2)
- if prefixes[n] and clrs[nn] then
- prefixes[n](clrs[nn])
- skip = skip +2
- if str:sub(pos+3,pos+3) ~= "@" then
- local n = str:sub(pos+3,pos+3)
- local nn = str:sub(pos+4,pos+4)
- if prefixes[n] and clrs[nn] then
- prefixes[n](clrs[nn])
- skip = skip +2
- end
- else
- skip = skip + 1
- end
- end
- elseif char == "\n" then
- print("")
- else
- toPrint = toPrint..char
- end
- if pos == #str then break end
- pos = pos + 1 + skip
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement