Advertisement
xXm0dzXx

Le Random Font Program

Dec 15th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. local version = "1.0"
  2. local fontLoaderVersion = 1
  3.  
  4. fs.makeDir( "fonts" )
  5.  
  6. local function addFont( name, text )
  7. local sName = "fonts/" ..name
  8. fs.delete( sName )
  9. file = fs.open( sName, "w" )
  10. file.write( text )
  11. file.close()
  12. end
  13.  
  14. addFont( "f4!1", [[48(d3f9h!jk1mn0pqr57uvwxy2
  15. 48(d3f9h!jk1mn0pqr57uvwxy2]] )
  16.  
  17. if usedThisProgramAgainYeaLolNoobHahaStopLookingAtThisCodeActuallyNVMiDontCareAnymoreDoWhateverYouWant == nil then
  18. usedThisProgramAgainYeaLolNoobHahaStopLookingAtThisCodeActuallyNVMiDontCareAnymoreDoWhateverYouWant = true
  19. oldWrite = term.write
  20. end
  21.  
  22. _cMCHARS = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }
  23. _lMCHARS = { }
  24.  
  25. for i=1,#_cMCHARS do
  26. table.insert( _lMCHARS, string.upper( _cMCHARS[ i ] ) )
  27. end
  28.  
  29. function loadFont( path, sType )
  30. if sType == nil then
  31. sType = fontLoaderVersion
  32. end
  33.  
  34. if sType == 1 then
  35. if fs.exists( path ) then
  36. local chars = _cMCHARS
  37. local file = fs.open( path, "r" )
  38. if file then
  39. local sLower = file.readLine()
  40. local sCaps = file.readLine()
  41.  
  42. _cMCHARS = {}
  43. _lMCHARS = {}
  44.  
  45. for i=1,#sLower do
  46. local currentChar = string.sub( sLower, i, i )
  47.  
  48. table.insert( _cMCHARS, currentChar )
  49. end
  50.  
  51. for i=1,#sCaps do
  52. local currentChar = string.sub( sCaps, i, i )
  53.  
  54. table.insert( _lMCHARS, currentChar )
  55. end
  56.  
  57. file.close()
  58.  
  59. return true
  60. end
  61. end
  62. else
  63. error("Invalid Font Version")
  64. end
  65.  
  66. return false
  67. end
  68.  
  69. local function isCaps( char )
  70. if string.upper( char ) == char then
  71. return true
  72. end
  73. return false
  74. end
  75.  
  76. local function getSpecial( char )
  77. local tNums = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }
  78. local tChar = string.lower( char )
  79. local tValue = 0
  80.  
  81. for i=1,#tNums do
  82. if tNums[ i ] == tChar then
  83. if isCaps( char ) then
  84. return _lMCHARS[ i ]
  85. else
  86. return _cMCHARS[ i ]
  87. end
  88. end
  89. end
  90.  
  91. return char
  92. end
  93.  
  94. term.write = function( text )
  95. local sText = ""
  96.  
  97. for i=1,#text do
  98. local sChar = string.sub( text, i, i )
  99. sText = sText.. getSpecial( sChar )
  100. end
  101.  
  102. return oldWrite( sText )
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement