Advertisement
ValveCantCount

printWithFormat

May 5th, 2015
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. function cprint(...)
  2.         local s = "&1"
  3.         for k, v in ipairs(arg) do
  4.                 s = s .. v
  5.         end
  6.         s = s .. "&0"
  7.  
  8.         local fields = {}
  9.         local lastcolor, lastpos = "0", 0
  10.         for pos, clr in s:gmatch"()&(%x)" do
  11.                 table.insert(fields, {s:sub(lastpos + 2, pos - 1), lastcolor})
  12.                 lastcolor, lastpos = clr , pos
  13.         end
  14.  
  15.         for i = 2, #fields do
  16.                 term.setTextColor(2 ^ (tonumber(fields[i][2], 16)))
  17.                 io.write(fields[i][1])
  18.         end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement