Atom888

XynSoft 0.0 - Shell API

Jan 10th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.76 KB | None | 0 0
  1. -- Copyright XiliØn Studios
  2. GuiList = {}
  3. --To clear the terminal
  4. function C()
  5.    term.clear()
  6. end
  7.  
  8. -- To set the cursor position (Arguments: X Coordinate, Y Coordinate )
  9. function CP(x,y)
  10.    term.setCursorPos(x,y)
  11. end
  12.  
  13. -- To set the background color (Arguments: Color < "colors." + Color >
  14. function BC(bgC)
  15.    term.setBackgroundColor(bgC)
  16. end
  17.  
  18. -- To set the text color (Arguments: Color < "colors." + Color >
  19. function TC(ttC)
  20.    term.setTextColor(ttC)
  21. end
  22.  
  23. -- To Write text [ Without having to write multiple commands ] (Arguments: The Text, Starting X Coordinate, Starting Y Coordinate, -- --- Background Color < "colors." + Color >, Text Color < "colors." + Color >)
  24. function Write(text,Wx,Wy,Wbc,Wtc)
  25.    CP(Wx,Wy)
  26.    BC(Wbc)
  27.    TC(Wtc)
  28.    term.write(text)
  29. end
  30.  
  31. function Input(text,rd,Ix,Iy,Ibc,Itc)
  32.    CP(Ix,Iy)
  33.    BC(Ibc)
  34.    TC(Itc)
  35.    term.write(text)
  36.    return read(rd)
  37. end
  38.  
  39. function F(ty,Fcoord,Fcol)
  40.    if ty == "h" then
  41.       BC(Fcol)
  42.       Cp(1,Fcoord)
  43.       term.clearLine()
  44.    elseif ty == "v" then
  45.       for i = 1,19 do
  46.          Write(" ",Fcoord,i,Fcol,Fcol)  
  47.       end
  48.    end
  49. end
  50.  
  51. function FS(fillCol,effect,side,eTime)
  52.     if effect then
  53.       if side == "left" then
  54.          for x = 1,51 do
  55.             F("v",x,fillCol)
  56.             sleep(eTime)
  57.          end
  58.       elseif side == "right" then
  59.          x = 52
  60.          for i = 1,51 do
  61.             x = x - 1
  62.             F("v",x,fillCol)
  63.          end
  64.       elseif side == "up" then
  65.          for y = 1,19 do
  66.             F("h",y,fillCol)
  67.          end
  68.       elseif side == "down" then
  69.          y = 20
  70.          for i = 1,19 do
  71.             y = y - 1
  72.             F("h",y,fillCol)
  73.          end  
  74.       end
  75.    else
  76.       for x = 1,45 do
  77.          F("v",x,fillCol)
  78.       end
  79.    end
  80. end
  81.  
  82. function Block(x1,y1,x2,y2,fill,col)
  83.    CP(x1,y1)
  84.    for xa1 = x1,x2 - x1 + 1 do
  85.       Write(" ",xa1,y1,col,col)
  86.    end
  87.    CP(x1,y1)
  88.    for ya1 = y1,y2 - y1 + 1 do
  89.       Write(" ",x1,ya1,col,col)
  90.    end
  91.    CP(x1,y2)
  92.    for xa2 = x1,x2 - x1 + 1 do
  93.       Write(" ",xa2,y2,col,col)
  94.    end
  95.    CP(x2,y1)
  96.    for ya2 = y1,y2 - y1 + 2 do
  97.       Write(" ",x2,ya2,col,col)
  98.    end
  99.    if fill then
  100.       for y = y1,y2 do
  101.          for x = x1,x2 do
  102.             Write(" ",x,y,col,col)
  103.          end
  104.       end
  105.    end
  106. end
  107.      
  108. function ShellEvent(evt)
  109.    a,b,c,d = os.pullEventRaw()
  110.    if a == evt then
  111.       return b,c,d
  112.    end      
  113. end
  114.  
  115. function ShellEventAdv(a,b,c,d,e,f)
  116.    evt,button,x,y = os.pullEventRaw()
  117.    if evt == a then
  118.       if button == b then
  119.          if x >= c then
  120.             if x <= d then
  121.                if y >= e then
  122.                   if y <= f then
  123.                      return true
  124.                   else
  125.                      return false
  126.                   end
  127.                else
  128.                   return false
  129.                end
  130.             else
  131.                return false
  132.             end
  133.          else
  134.             return false
  135.          end
  136.       else
  137.          return false
  138.       end
  139.    else
  140.       return false
  141.    end
  142. end
  143.  
  144. function PastebinGet(PBcode,Fpath)
  145.    http.get(PBcode,Fpath)
  146. end
  147.  
  148. function FsDel(Fpath)
  149.    fs.delete(Fpath)
  150. end
  151.  
  152. function FsMkdir(dir)
  153.    fs.makeDir(dir)
  154. end
  155.  
  156. function FsExists(file)
  157.    return fs.exists(file)
  158. end
  159.  
  160. function FsMake(path)
  161.    local f = fs.open(path)
  162.    f.close()
  163. end
  164.  
  165. function ReadAll(file)
  166.    local f = fs.open(file)
  167.    local data = f.readAll()
  168.    f.close()
  169.    return data
  170. end
  171.  
  172. function GlobalWrite(file,writeData)
  173.    local f = fs.open(file)
  174.    f.write(writeData)
  175.    f.close()
  176. end
  177.  
  178. function OsReboot()
  179.    os.reboot()
  180. end
  181.  
  182. function OsShutdown()
  183.    os.shutdown()
  184. end
  185.  
  186. function Api(api)
  187.    os.loadAPI(api)
  188. end
  189.  
  190. function Image(Image,x,y)
  191.    local img = paintutils.loadImage(Image)
  192.    paintutils.drawImage(img,x,y)
  193. end
  194.  
  195. function Button(text,x,midY,bgC,ttC)
  196.    for x1 = x,(x + (string.len(text))) + 1 do
  197.       Write(" ",x1,midY - 1,bgC,ttC)
  198.    end
  199.    Write(" "..text.." ",x,midY,bgC,ttC)
  200.    for x1 = x,(x + (string.len(text))) + 1 do
  201.       Write(" ",x1,midY + 1,bgC,ttC)
  202.    end
  203. end
  204.  
  205. function KernelOp(code,prog)
  206.    if code == 0001 then
  207.       shell.run("/XynSoft/System/Troubleshoot/Ts")
  208.    elseif code == 0000 then
  209.       shell.run("/XynSoft/System/Ops/Shutdown")
  210.    elseif code == 1000 then
  211.       shell.run("/XynSoft/System/Ops/Logoff")
  212.    elseif code == 1111 then
  213.       shell.run("/XynSoft/System/Ops/AppRun",prog)
  214.    end
  215. end
  216.  
  217. function DrawTitleBar(TitleTxt,bgColor,SubTxt,xCoord)
  218.    F("h",1,bgColor)
  219.    F("h",2,bgColor)
  220.    F("h",3,bgColor)
  221.    local x = xCoord + (string.len(TitleTxt) + 2)
  222.    Write(TitleTxt,xCoord,2,bgColor,colors.white)
  223.    Write(SubTxt,x,2,bgColor,colors.lightGray)
  224. end
  225.  
  226. -- function SetAlias(aliasName,appPath)
  227. -- |||  
  228. -- end
Advertisement
Add Comment
Please, Sign In to add comment