Guest User

build.lua

a guest
Mar 12th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. -- Table of program name - pastebin string pairs
  2. local progTable = {
  3.     {"quarry",     "HKvSqARi"},
  4.     {"stripmine",  "7Q3kjTQB"}
  5. }
  6.  
  7.  
  8. function main()
  9.     if (arg[1] == nil) then
  10.         print("Specify a program")
  11.         return
  12.     end
  13.    
  14.     -- get the value from the table
  15.     target = nil
  16.     for i = 1, #progTable do
  17.         if (arg[1] == progTable[i][1]) then
  18.             target = progTable[i][2]
  19.         end    
  20.     end
  21.    
  22.     if (target == nil) then
  23.         print("Target not found.")
  24.         return
  25.     end
  26.    
  27.     name = arg[1] .. ".lua"
  28.     -- the program was found
  29.     -- remove the current version
  30.     res1 = shell.run("rm", name)
  31.     -- get the new version
  32.     res2 = shell.run("pastebin", "get", target, name)
  33.    
  34.     if (res1 and res2) then
  35.         print("Fetched " .. name)    
  36.     else
  37.         print("Fetch failed")
  38.     end    
  39. end
  40.  
  41. main()
Advertisement
Add Comment
Please, Sign In to add comment