I am trying to copy from my computer to my pocket computer and used the following code:
fs.copy("9tyninecraft","disk/test")
And I got File already exists although there is no program called test on either computer
I am running it in a program I think it is because I didn't wrap my peripheral
if term.isColor() == true then
BgC = colors.blue
BdC = colors.green
elseif term.isColor() == false then
BgC = colors.black
BdC = colors.white
end
Padges = {{"World Eater","Sorting","Move",
"Games","Calculator","Disk","Options","Help","Exit"},
{"Start","Help","Exit"},{"Check Disk","Startup","9TYNINECRAFT","Calculator","Help","Exit"}}
PdN = 1
CuS = 0
TxC = colors.white
ScW,ScH = term.getSize()
Running = true
function Padge()
term.setBackgroundColor(BgC)
term.clear()
term.setBackgroundColor(BdC)
term.setCursorPos(1,1)
for i = 1,ScW do
term.write(" ")
end
for i = 2,ScH do
term.setCursorPos(1,i)
term.write(" ")
term.setCursorPos(ScW,i)
term.write(" ")
end
term.setCursorPos(1,ScH)
for i = 1,ScW do
term.write(" ")
end
term.setCursorPos(2,2)
term.setBackgroundColor(BgC)
end
function List()
term.setCursorPos(2,2)
MaxN = table.maxn(Padges[PdN])
for i = 1,MaxN do
row = i
CurentPadge = Padges[PdN]
Hlght()
term.write(CurentPadge[i])
term.setCursorPos(2,i+2)
end
end
function SeL()
p1,p2 = os.pullEvent()
if p2 == 208 then
if CuS ~= MaxN then
CuS = CuS+1
elseif CuS == MaxN then
CuS = 1
end
elseif p2 == 200 then
if CuS > 1 then
CuS = CuS-1
else
CuS = MaxN
end
elseif p2 == 28 then
if PdN == 1 then
if CuS == 1 then
Padge()
PdN = 2
CuS = 0
elseif CuS == 5 then
shell.run("Calculator")
elseif CuS == 6 then
Padge()
PdN = 3
CuS = 0
elseif CuS == MaxN then
Running = false
end
elseif PdN == 2 then
if CuS == 1 then
WorldEater()
elseif CuS == MaxN then
Padge()
PdN = 1
CuS = 1
end
elseif PdN == 3 then
if CuS == 1 then
Padge()
Check_Disk()
sleep(2)
elseif CuS == 2 then
--fs.delete("startup","disk2")
fs.copy("startup",DiskM.."/startup")
elseif CuS == 3 then
fs.copy("9TYNINECRAFT",DiskM.."/9TYNINECRAFT")
elseif CuS == 4 then
fs.copy("Calculator",DiskM.."/Calculator")
end
end
end
end
function Hlght()
if CuS == row then
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
elseif CuS ~= i then
term.setBackgroundColor(BgC)
term.setTextColor(TxC)
end
end
function Check_Disk()
Padge()
term.write("What Side is your disk drive on? ")
Disk = peripheral.wrap(io.read())
if Disk.isDiskPresent() then
Padge()
DiskM = Disk.getMountPath()
term.write("Disk found")
else
Padge()
term.write("No disk found")
end
end
sleep(.5)
Padge()
List()
while Running do
List()
SeL()
--term.setCursorPos(7,7)
--term.write(MaxN)
--term.setCursorPos(8,8)
--term.write(CuS)
sleep(.15)
end
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
term.setCursorPos(1,1)
term.write("Thank you for using 9TYNINECRAFT")
term.setCursorPos(1,2)
Cool thanks that fixes that now I can't delete it it keeps telling me that it wants a string even if I put
fs.delete("startup","disk2")
fs.delete("disk2/startup")
local DiskM
I would suggest using fs.combinewould fs.delete(DiskM.."/startup") be the correct phrasing
also how do i run a pastebin from a program
shell.run("pastebin run <code>")
The other way would be to download the program using the http api and execute it:
if not http then --Check if http API is enabled
error("HTTP needs to be enabled!")
end
local handle = http.get("http://pastebin.com/raw/<code>") --Get the data from pastebin
local content = handle.readAll() --Read everything from the web page
handle.close() --Close the handle
loadstring(content)()
--Loadstring can make a function out of the lua source code