Wiiplay123

KAS2 Disk Maker

Jun 24th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. -- KAS2 Disk Maker
  2.  
  3. print("KAS2 Disk Maker")
  4. local disks = {}
  5. for i, v in pairs(peripheral.getNames()) do
  6.   if peripheral.getType(v) == "drive" then
  7.     if disk.isPresent(v) then
  8.       table.insert(disks,v)
  9.     end
  10.   end
  11. end
  12. write("Disk Name: ")
  13. local name = read()
  14. local file = "**"
  15. while true do
  16.   write("Game Executable File: ")
  17.   file = read()
  18.   if fs.exists(file) then
  19.     break
  20.   end
  21. end
  22. if #disks == 0 then
  23.   error("No disks present.",0)
  24. elseif #disks == 1 then
  25.   diskz = disks[1]
  26. else
  27.   while true do
  28.     for i, v in pairs(disks) do
  29.       print(i..". "..v)
  30.     end
  31.     local choice = 0
  32.     choice = tonumber(read())
  33.     if choice > 0 and choice <= #disks then
  34.       diskz = disks[choice]
  35.       break
  36.     end
  37.   end
  38. end
  39. local list = fs.list(disk.getMountPath(diskz))
  40. for i, v in pairs(list) do
  41.   fs.delete(disk.getMountPath(diskz).."/"..v)
  42. end
  43. disk.setLabel(diskz,name)
  44. local filez = fs.open(disk.getMountPath(diskz).."/kas2info","w")
  45. filez.write(textutils.serialize(({["name"] = name})))
  46. filez.close()
  47. fs.copy(file,disk.getMountPath(diskz).."/kas2game")
Advertisement
Add Comment
Please, Sign In to add comment