Advertisement
kremnev8

TABLET CONTROL CLIENT

Feb 17th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.86 KB | None | 0 0
  1. -------------------- CONFFIG ---------------------
  2. --this lines you can edit
  3. ID = "MAIN" -- tablet ID
  4. os.loadAPI("AF") -- crypting/decrypting API by Zer0Galaxy
  5. key = AF.getkey("HsGT4*523GuH") --key
  6. --------------------------------------------------
  7. pr = false
  8. ex = true
  9. m = peripheral.wrap("back")
  10. lsms = {}
  11. m.open(50)
  12. term.clear()
  13. term.setCursorPos(1,1)
  14.  
  15.  
  16.  --crypt message and send
  17. function sendC(ms)
  18. pms = AF.crypt(ms,key)
  19. m.transmit(50,50,pms)
  20. end
  21.  
  22.  -- gmatch universal
  23. function Gmatch(text,form)
  24. for h,k,v in string.gmatch(text,form) do
  25. return h,k,v
  26. end
  27. end
  28.  
  29.  --recive and decrypt
  30. function RDEC()
  31. e,p1,p2,p3,p4,p5 = os.pullEvent()
  32. if e == "modem_message" then
  33. Oms = AF.decrypt(p4,key)
  34. return tostring(Oms)
  35. end
  36. end
  37.  
  38.  
  39. function os.pullEvent()
  40. e,p1,p2,p3,p4,p5 = os.pullEventRaw()
  41. if e == "modem_message" then
  42. ms = AF.decrypt(p4,key)
  43. end
  44. return e,p1,p2,p3,p4,p5
  45. end
  46.  
  47.  
  48. st = 0
  49. while ex do
  50. st = st + 1
  51. if st == 1 then
  52. print("welcome to console")
  53. print('type "help" to help')
  54. end
  55. write("sys>")
  56. inp = read(_,lsms)
  57. table.insert(lsms,inp)
  58.  
  59. if inp == "add" then
  60. print("write player to add:")
  61. inp = read()
  62. m.transmit(50,50,AF.crypt("add="..inp,key))
  63.  
  64. elseif inp == "rm" then
  65. print("write player to remove:")
  66. inp = read()
  67. m.transmit(50,50,AF.crypt("rm="..inp,key))
  68.  
  69. elseif inp == "rOpen" then
  70. write("write door ID:")
  71. inp = read()
  72. m.transmit(50,50,AF.crypt("rOpen="..inp,key))
  73.  
  74. elseif inp == "getEU" then
  75. m.transmit(50,50,AF.crypt("getEU=sys",key))
  76. ms = RDEC()
  77. print(ms)
  78.  
  79. elseif inp == "trm" then
  80. ex = false
  81.  
  82. elseif inp == "clear" then
  83. term.clear()
  84. term.setCursorPos(1,1)
  85.  
  86. elseif inp == "getRCS" then
  87. m.transmit(50,50,AF.crypt("getRCS=sys",key))
  88. ms = RDEC()
  89. H,AC,EU = Gmatch(ms,"%w+=(%w+);(%w+);(%w+)")
  90. if AC == "true" then
  91. print("now reactor Enabled")
  92. print("Heat is "..H..", now Output is "..EU)
  93. else
  94. print("now reactor Disabled")
  95. end
  96. elseif inp == "getDS" then
  97.  
  98. m.transmit(50,50,AF.crypt("getDS=server1",key))
  99. ms = RDEC()
  100. print(ms)
  101. ---------------------------------------------------------
  102. --there you can add you function  "inp" is player input.   A[1] is command , [2] is args
  103.  
  104.  
  105.  
  106. ---------------------------------------------------------
  107. elseif inp == "help" then
  108. m.transmit(50,50,AF.crypt("getHelp",key))
  109. mg = RDEC()
  110.  
  111. ms = {"in this system were this commands:",
  112.       "-add , takes this: <player> to add in system",
  113.       "-rm ,  takes this: <player> to remove from system",
  114.       "-rOpen , takes this: <Door ID> to open",
  115.       "-getEU , returns energy in system storage",
  116.       "-getDS , returns distance to server",
  117.       "-getRCS , return status of reactor",
  118.       "this programs not require access to server",
  119.       "-trm , terminate program",
  120.       "-clear , clear screen"}
  121. term.clear()
  122. term.setCursorPos(1,1)
  123. for i=1,#ms do
  124. if i > 22 then
  125. os.pullEvent("key")
  126. end
  127. print(ms[i])
  128. sleep(0)
  129. end
  130. end
  131. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement