Posted 30 April 2012 - 02:53 PM
This is a simple program I made a while ago that allows you to easily and quickly copy files to a floppy and label it so you can easily publish programs on servers and such; mass-produce a game on a server for in-game currency, for example! I'll work on adding more features as well, such as copying multiple files.It is currently a little buggy so I will also work on fixing things up for it.
How to get it
For cc-get: cc-get install program_publisher
cc-get website link: http://cc-get.djrang...scripts/view/64
Pastebin: http://pastebin.com/LXW4ZxS6
Source code:
[/left]
How to get it
For cc-get: cc-get install program_publisher
cc-get website link: http://cc-get.djrang...scripts/view/64
Pastebin: http://pastebin.com/LXW4ZxS6
Source code:
Spoiler
---------------------------
-- Automatic File Copier --
-- For CC --
---------------------------
-- Written by Onionnion --
--------------------------------------------------
-- This script is released with the CC license! --
---------------- Go crazy with it! ---------------
--------------------------------------------------
function resetScreen(quitQ,numberMade,label) -- function that resets the screen
term.clear() -- clears terminal
term.setCursorPos(1,1) -- sets cursor's position
if quitQ == true then --if quitQ is true, which starts out as false at line 10
if label == nil then
print("Current disk label: numerical")
elseif label == 0 then
print("Current disk label: None")
else
print("Current disk label: "..label)
end
print("Copies Made: "..tostring(numberMade)) -- prints total made
print("Press L to change the label.")
print("Press C to change the copying operation.")
print("Press Q to quit.")
end
end
function labeler()
while true do
resetScreen()
print("How would you like label the disks?n(Enter number for selection.)")
print("1: Number (1, 2, 3..etc.)")
print("2: Custom Label")
print("3: No label")
local whatDo = read()
if whatDo == "1" then
label = nil
break
elseif whatDo == "2" then
resetScreen()
write("Enter the label: ")
label = read()
break
elseif whatDo == "3" then
label = 0
break
else
resetScreen()
print("Not a correct input, try again")
sleep(2)
end
end
resetScreen(quitQ,numberMade,label)
end
function copyChange()
while true do -- file I/O
resetScreen()
write("File to Copy: ")
fileIn = read() -- input file
write("Location/Name to copy to: ")
fileOut = read() -- output file
if fs.exists(fileIn) == false or fs.exists(fileOut) == true then -- if input file isn't there or if output file already exists
resetScreen()
print("Invalid inputs! Try again.")
print("(Maybe file incorrect file to be copied or file to be created is already there?)")
sleep(2)
else
break
end
end
resetScreen(quitQ,numberMade,label)
end
local side = "" -- side disk drive is on
local numberMade = 0 -- keeps track of how many were made
local quitQ = false -- quitQ is going to be short for quit-Question, meaning if false,
-- do not display the option to quit yet until able to
resetScreen(quitQ)
print("Insert a disk into the drive to be used.")
while true do
local event, param = os.pullEvent()
if event == "disk" then
side = param
break
end
end
labeler()
copyChange()
quitQ = true -- sets quitQ to true
-- it's always a good idea to keep comments orderly like you see here and above
while true do
resetScreen(quitQ,numberMade,label)
event, param = os.pullEvent()
if event == "disk" then
if fs.exists(fileOut) == true then -- if the file is already there (can't overwrite with cp!)
print("File already there! Please insert another disk.")
print("Press any button to eject and continue.")
while true do
local event = os.pullEvent()
if event == "char" or event == "key" then
disk.eject(side)
resetScreen(quitQ,numberMade)
break
end
end
else
shell.run("/rom/programs/copy", fileIn, fileOut) -- runs copy (cp) with the variables
if label ~= nil and label ~= 0 then
disk.setLabel(side, label)
elseif label == 0 then
---
else
disk.setLabel(side, tostring(numberMade + 1))
end
numberMade = numberMade + 1 -- add one to the count
disk.eject(side)
resetScreen(quitQ,numberMade,label)
end
end
if event == "char" and param == "l" then
labeler()
elseif event == "char" and param == "c" then
copyChange()
elseif event == "char" and param == "q" then -- test if quit button was pressed
break -- break exits the loop; jumps right down to the 'print'
end
end
quitQ = false
resetScreen(quitQ)
print("Bye!")
sleep(1)
resetScreen(quitQ)
[left]