Atom888

XynSoft 1.0 - Shell API

Nov 2nd, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.22 KB | None | 0 0
  1. function C()
  2.    term.clear()
  3. end
  4.  
  5. function CP(x,y)
  6.    term.setCursorPos(x,y)
  7. end
  8.  
  9. function BC(bgC)
  10.    term.setBackgroundColor(bgC)
  11. end
  12.  
  13. function TC(ttC)
  14.    term.setTextColor(ttC)
  15. end
  16.  
  17. function Write(text,Wx,Wy,Wbc,Wtc)
  18.    CP(Wx,Wy)
  19.    BC(Wbc)
  20.    TC(Wtc)
  21.    term.write(text)
  22. end
  23.  
  24. function Input(text,rd,Ix,Iy,Ibc,Itc)
  25.    CP(Ix,Iy)
  26.    BC(Ibc)
  27.    TC(Itc)
  28.    term.write(text)
  29.    return read(rd)
  30. end
  31.  
  32. function F(ty,Fcoord,Fcol)
  33.    if ty == "h" then
  34.       Write("                                                                                                     ",1,Fcoord,Fcol,Fcol)
  35.    elseif ty == "v" then
  36.       for i = 1,19 do
  37.          Write(" ",Fcoord,i,Fcol,Fcol)  
  38.       end
  39.    end
  40. end
  41.  
  42. function FS(fillCol,effect,eTime)
  43.    y = 1        
  44.    if effect then
  45.       for y = 1,19 do
  46.          F("h",y,fillCol)
  47.          sleep(eTime)
  48.       end
  49.    elseif not effect then
  50.       for y = 1,19 do
  51.          F("h",y,fillCol)
  52.       end
  53.    end
  54. end
  55.  
  56. function FV(side,fillCol,effect,eTime)
  57.    if effect then
  58.       if side == "left" then
  59.          for x = 1,45 do
  60.             F("v",x,fillCol)
  61.             sleep(eTime)
  62.          end
  63.       elseif side == "right" then
  64.          x = 45
  65.          for i = 1,45 do  
  66.             x = x - 1
  67.             F("v",x,fillCol)
  68.          end
  69.       end
  70.    else
  71.       for x = 1,45 do
  72.          F("v",x,fillCol)
  73.       end
  74.    end
  75. end
  76.  
  77. function Block(x1,y1,x2,y2,fill,col)
  78.    CP(x1,y1)
  79.    for xa1 = x1,x2 - x1 + 1 do
  80.       Write(" ",xa1,y1,col,col)
  81.    end
  82.    CP(x1,y1)
  83.    for ya1 = y1,y2 - y1 + 1 do
  84.       Write(" ",x1,ya1,col,col)
  85.    end
  86.    CP(x1,y2)
  87.    for xa2 = x1,x2 - x1 + 1 do
  88.       Write(" ",xa2,y2,col,col)
  89.    end
  90.    CP(x2,y1)
  91.    for ya2 = y1,y2 - y1 + 2 do
  92.       Write(" ",x2,ya2,col,col)
  93.    end
  94.    if fill then
  95.       for y = y1,y2 do
  96.          for x = x1,x2 do
  97.             Write(" ",x,y,col,col)
  98.          end
  99.       end
  100.    end
  101. end
  102.      
  103. function ShellEvent(evt)
  104.    a,b,c,d = os.pullEventRaw()
  105.    if a == evt then
  106.       return b,c,d
  107.    end      
  108. end
  109.  
  110. function ShellEventAdv(a,b,c,d,e,f)
  111.    evt,button,x,y = os.pullEventRaw()
  112.    if evt == a then
  113.       if button == b then
  114.          if x >= c then
  115.             if x <= d then
  116.                if y >= e then
  117.                   if y <= f then
  118.                      return true
  119.                   else
  120.                      return false
  121.                   end
  122.                else
  123.                   return false
  124.                end
  125.             else
  126.                return false
  127.             end
  128.          else
  129.             return false
  130.          end
  131.       else
  132.          return false
  133.       end
  134.    else
  135.       return false
  136.    end
  137. end
  138.  
  139. function PastebinGet(PBcode,Fpath)
  140.    http.get(PBcode,Fpath)
  141. end
  142.  
  143. function FsDel(Fpath)
  144.    fs.delete(Fpath)
  145. end
  146.  
  147. function FsMkdir(dir)
  148.    fs.makeDir(dir)
  149. end
  150.  
  151. function FsExists(file)
  152.    return fs.exists(file)
  153. end
  154.  
  155. function FsMake(path)
  156.    local f = fs.open(path)
  157.    f.close()
  158. end
  159.  
  160. function ReadAll(file)
  161.    local f = fs.open(file)
  162.    local data = f.readAll()
  163.    f.close()
  164.    return data
  165. end
  166.  
  167. function GlobalWrite(file,writeData)
  168.    local f = fs.open(file)
  169.    f.write(writeData)
  170.    f.close()
  171. end
  172.  
  173. function OsReboot()
  174.    os.reboot()
  175. end
  176.  
  177. function OsShutdown()
  178.    os.shutdown()
  179. end
  180.  
  181. function Api(api)
  182.    os.loadAPI(api)
  183. end
  184.  
  185. function Image(Image,x,y)
  186.    local img = paintutils.loadImage(Image)
  187.    paintutils.drawImage(img,x,y)
  188. end
  189.  
  190. function Button(text,x,midY,bgC,ttC)
  191.    for x1 = x,(x + (string.len(text))) + 1 do
  192.       Write(" ",x1,midY - 1,bgC,ttC)
  193.    end
  194.    Write(" "..text.." ",x,midY,bgC,ttC)
  195.    for x1 = x,(x + (string.len(text))) + 1 do
  196.       Write(" ",x1,midY + 1,bgC,ttC)
  197.    end
  198. end
  199. Data = {
  200.     ,function GetType(data)
  201.        return type(data)
  202.     end,
  203.     Str = {
  204.        function Length(string)
  205.           return string.len(string)
  206.        end,
  207.        function GM(a,b)
  208.           return string.gmatch(a,b)
  209.        end
  210.     },
  211.     List = {
  212.        function ReturnItem(lst,index)
  213.           return lst[index]
  214.        end,
  215.        function ReturnAllIndexTable(lst)
  216.           s = 0
  217.           t = {}
  218.           for i in lst do
  219.              table.insert(s,i,t)
  220.           end
  221.           return t
  222.        end,
  223.        function Insert(ins,lst)
  224.           table.insert(ins,lst)
  225.        end,
  226.        function ReturnSelf(lst)
  227.           return lst
  228.        end,
  229.        function ReturnIndexes(lst)
  230.           s = 0
  231.           l = {}
  232.           for i in lst do
  233.              table.insert(s,l)
  234.              s = s + 1
  235.           end
  236.           return l
  237.        end
  238.    },
  239.    Tabl = {
  240.        function Insert(key,v,tabl)
  241.           table.insert(key,v,tabl)
  242.        end,  
  243.        function ReturnItem(key,tabl)
  244.           return tabl[key]
  245.        end,
  246.        function ReturnSelf(tabl)
  247.           return tabl
  248.        end,
  249.        function ReturnKey(tabl)
  250.           l = {}
  251.           for key,i in pairs(tabl) do
  252.              table.insert(key,l)
  253.           end
  254.           return l
  255.        end
  256.    }    
  257. }
  258. System = {
  259.    ,FileSystem = {
  260.       ,function GetFileListening(dir)
  261.          return fs.list(dir)
  262.       end,
  263.       function GetFileSystemList()
  264.          tabl = {}
  265.          for a in fs.list("/") do
  266.             for b in fs.list("/"..a) do
  267.                for c in fs.list("/"..a.."/"..b) do
  268.                   for d in fs.list("/"..a.."/"..b.."/"..c) do
  269.                      for e in fs.list("/"..a.."/"..b.."/"..c.."/"..d) do
  270.                         for f in fs.list("/"..a.."/"..b.."/"..c.."/"..d.."/"..e) do
  271.                            table.insert(fs.list("/"..a.."/"..b.."/"..c.."/"..d.."/"..e.."/"..f),tabl)
  272.          end
  273.             end
  274.                end
  275.                   end
  276.                      end
  277.                         end
  278.          return tabl
  279.       end,
  280.       function CheckDirForExistingFiles(tab,dir)
  281.          a = fs.list(tab)
  282.          retrn = {}
  283.          for f in a do
  284.             if f in tab then
  285.                table.insert(f,"True",retrn)
  286.             else
  287.                table.insert(f,"False",retrn)
  288.             end
  289.          end
  290.          return retrn
  291.       end
  292.    },
  293.    Http = {
  294.       ,function Get(code,file)
  295.          http.get(code,file)
  296.       end,
  297.       function Put(file)
  298.          http.put(file)
  299.       end
  300.    }  
  301. }
Advertisement
Add Comment
Please, Sign In to add comment