Advertisement
Mr_jack

sysapi

Jan 23rd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. function Touchzone(sX,sY,eX,eY,event,key)
  2.   e,p1,p2,p3,p4 = os.pullEvent()
  3.     if e == event and p1 == key and p2 >= sX and eX >= p2 and p3 >= sY and eY >= p3 then
  4.       return true
  5.     else
  6.       return false
  7.     end
  8. end
  9.  
  10. function Touchzone_raw(x,y,e,key,sX,sY,eX,eY,event,k)
  11.   if event == e and key == k and x >= sX and eX >= x and y >= sY and eY >= y then
  12.     return true
  13.   else
  14.     return false
  15.   end    
  16. end                    
  17.  
  18. function Button(x,y,text,col,col2)
  19.   term.setBackgroundColor(col)
  20.   term.setTextColor(col2)
  21.   size = #text+1
  22.   paintutils.drawLine(x,y,x+size,y,col)
  23.   term.setCursorPos(x+1,y)
  24.   write(text)
  25.   term.setCursorPos(1,1)
  26.   e,p1,p2,p3,p4 = os.pullEvent()
  27.     if e == "mouse_click" and p1 == 1 and p2 >= x and x+size >= p2 and p3 == y then
  28.       return true
  29.     else
  30.       return false
  31.     end
  32. end
  33.  
  34. function Draw_button(x,y,text,col,col2)
  35.   term.setBackgroundColor(col)
  36.   term.setTextColor(col2)
  37.   term.setCursorPos(x,y)
  38.   write(" "..text.." ")
  39. end
  40.  
  41. function ClearScr(color)
  42.   paintutils.drawPixel(1,1,color)
  43.   term.clear()
  44. end
  45.  
  46. function Text(x,y,text,color,color2)
  47.   term.setTextColor(color)
  48.   term.setBackgroundColor(color2)
  49.   term.setCursorPos(x,y)
  50.   print(text)
  51. end
  52.  
  53. function setCol(col1,col2)
  54.   term.setBackgroundColor(col1)
  55.   term.setTextColor(col2)
  56. end
  57.  
  58. function getSysInfo()
  59.   id = os.getComputerID()
  60.   label = os.getComputerLabel()
  61.   return id,label
  62. end
  63.  
  64.  
  65. function FindPeri(find)
  66.   list = peripheral.getNames()
  67.   for i=1,#list do
  68.     if peripheral.getType(list[i]) == find then
  69.       return list[i]
  70.     end
  71.   end
  72. end
  73.  
  74. function LoadConfig(path,line)
  75.   file = fs.open(path,"r")
  76.   for i=1,line-1 do
  77.     file.readLine()
  78.   end
  79.   string = file.readLine()
  80.   num = string.find(string,"=")
  81.   if num ~= nil then
  82.   string = string.sub(string,num+1)
  83.   return string
  84.   end
  85. end
  86.  
  87. function WriteConfig(path,name,line,data)
  88.   file = fs.open(path,"w")
  89.   for i=1,line-1 do
  90.     file.writeLine()
  91.   end
  92.   if data ~= nil then
  93.   file.writeLine(name.."="..data)
  94.   file.close()
  95.   end
  96. end
  97.  
  98. function EditLine(path,line,text)
  99.   file = fs.open(path,"w")
  100.   for i = 1,line-1 do
  101.     file.writeLine()
  102.   end
  103.   file.writeLine(text)
  104.   file.close()
  105. end
  106.  
  107. function ReadLine(path,line)
  108.   file = fs.open(path,"r")
  109.   for i = 1,line-1 do
  110.     file.readLine()
  111.   end
  112.   return file.readLine()
  113. end
  114.  
  115. function centText(y,text)
  116.   iX,iY = term.getSize()
  117.   x = iX/2
  118.   x = x-#text/2
  119.   term.setCursorPos(x,y)
  120.   print(text)
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement