kd2bwzgen

guiapi

Jun 15th, 2017
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. local gcolors = {}
  2. if term.isColor() then
  3. gcolors.header = colors.yellow
  4. gcolors.text = colors.white
  5. gcolors.redtext = colors.red
  6. gcolors.greentext = colors.green
  7. else
  8. gcolors.header = colors.gray
  9. gcolors.text = colors.white
  10. gcolors.redtext = colors.lightgray
  11. gcolors.greentext = colors.lightgray
  12. end
  13. local function printWithColor(s,c)
  14. local oc = term.getTextColor()
  15. term.setTextColor(c)
  16. print(s)
  17. term.setTextColor(oc)
  18. end
  19. function header(s) printWithColor(s,gcolors.header) end
  20. function text(s) printWithColor(s,gcolors.text) end
  21. function ctext(s,c)
  22. if c=="red" then printWithColor(s,gcolors.redtext) else if c=="green" then printWithColor(s,gcolors.greentext) else error("MRGUI: Invalid ctext color!",0) end end
  23. end
  24. function redtext(s) ctext(s,"red") end
  25. function greentext(s) ctext(s,"green") end
  26. function getColor(k)
  27. if k=="red" then return getColor("redtext") end
  28. if k=="green" then return getColor("greentext") end
  29. return gcolors[k]
  30. end
  31. function setColor(k,v)
  32. if k=="red" then setColor("redtext",v) end
  33. if k=="green" then setColor("greentext",v) end
  34. gcolors[k] = v
  35. end
Advertisement
Add Comment
Please, Sign In to add comment