Stolar228

[OC] (MineOS) ASCII+

Jan 26th, 2019
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. local image = require("image")
  2. local GUI = require("GUI")
  3.  
  4. local text1
  5. local text2
  6. local text11
  7. local text22
  8. local slovo
  9. local g
  10. function saveascii()
  11. file = io.open("ascii.txt", "a")
  12. file:write(g)
  13. file:close()
  14. end
  15. function openascii()
  16. file = io.open("ascii.txt", "r")
  17. buf = file:read()
  18. file:close()
  19. end
  20. function clearascii()
  21. file = io.open("ascii.txt", "wb")
  22. file:close()
  23. end
  24. function code()
  25. clearascii()
  26. for i = 1,string.len(text1.text) do
  27. g = string.byte(text1.text,i).. "/"
  28. saveascii()
  29. end
  30. openascii()
  31. text2.text = buf
  32. end
  33. local s
  34. local ss
  35. local sl
  36. local i
  37. function decode()
  38. clearascii()
  39. s = 1
  40. while true do
  41. if (s + 1) > string.len(text2.text) then break end
  42. ss = string.find(text2.text,"/",s)
  43. sl = string.sub(text2.text,s,ss-1)
  44. g = string.char(sl)
  45. saveascii()
  46. s = ss + 1
  47. end
  48. openascii()
  49. text1.text = buf
  50. end
  51. local application = GUI.application()
  52. application:addChild(GUI.panel(1, 1, application.width, application.height, 0x1E1E1E))
  53. local window = application:addChild(GUI.titledWindow(50, 22, 60, 25, "ASCII +", true))
  54. window.actionButtons.close.onTouch = function()
  55. window2:close()
  56. application:draw()
  57. end
  58. local layout = window:addChild(GUI.layout(1, 2, window.width, window.height - 1, 1, 1))
  59. layout:addChild(GUI.button(1, 1, 36, 3, 0xB4B4B4, 0xFFFFFF, 0x969696, 0xB4B4B4, "code")).onTouch = function()
  60. code()
  61. end
  62. layout:addChild(GUI.button(1, 1, 36, 3, 0xB4B4B4, 0xFFFFFF, 0x969696, 0xB4B4B4, "decode")).onTouch = function()
  63. decode()
  64. end
  65. text1 = layout:addChild(GUI.input(1, 1, 40, 3, 0xFFFFFF, 0x555555, 0x999999, 0xFFFFFF, 0x2D2D2D, "", "code"))--.onInputFinished = function()
  66.  
  67.  
  68. text2 = layout:addChild(GUI.input(2, 2, 40, 3, 0xFFFFFF, 0x555555, 0x999999, 0xFFFFFF, 0x2D2D2D, "", "decode"))
  69.  
  70. layout:addChild(GUI.button(1, 1, 36, 3, 0xB4B4B4, 0xFFFFFF, 0x969696, 0xB4B4B4, "clear")).onTouch = function()
  71. text1.text = ""
  72. text2.text = ""
  73. end
  74. application:draw(true)
  75. application:start()
Advertisement
Add Comment
Please, Sign In to add comment