Advertisement
Inksaver

toolkitTutorial

Apr 18th, 2020
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. -- use with https://pastebin.com/26SS7P04
  2. local menu, T
  3.  
  4. function checkLabel()
  5.     if os.getComputerLabel() == nil then
  6.         os.setComputerLabel("toolkit")
  7.         print("Computer label set to "..os.getComputerLabel())
  8.     end
  9. end
  10.  
  11. function checkLibs(libDir, filename)
  12.     local fileExists = false
  13.     if fs.exists(libDir) then
  14.         if not fs.isDir(libDir) then
  15.             fs.move(libDir, libDir.."Renamed")
  16.             fs.makeDir(libDir)
  17.         end
  18.     else
  19.         fs.makeDir(libDir)
  20.     end
  21.     if fs.exists(fs.combine(libDir, filename)) or fs.exists(fs.combine(libDir, filename..".lua")) then
  22.         fileExists = true
  23.     end
  24.     return fileExists
  25. end
  26.  
  27. function main()
  28.     local doContinue = true
  29.     checkLabel() -- make sure turtle label is set
  30.     --check if lib folder exists
  31.     if not checkLibs("lib", "clsTurtleTutorial") then
  32.         print("Missing clsTurtle.lua in libs directory")
  33.         doContinue = false
  34.         -- or use pastebin get to download clsTurtle to libs folder
  35.     end
  36.     if not checkLibs("lib", "menu") then
  37.         print("Missing menu.lua in libs directory")
  38.         doContinue = false
  39.         -- or use pastebin get to download menu.lua to libs folder
  40.     end
  41.     if doContinue then
  42.         menu = require("lib.menu") --note alternative method of sub-folder
  43.         T = require("lib/clsTurtleTutorial").new("Tutorial Turtle")
  44.         print("My name is "..T:getName())
  45.         print("Thank you for using 'survival toolkit'")
  46.     else
  47.         print("Add missing files and restart")
  48.     end
  49. end
  50.  
  51. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement