This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
AstronautG117's profile picture

Pastebin Replace Program

Started by AstronautG117, 16 December 2012 - 10:38 AM
AstronautG117 #1
Posted 16 December 2012 - 11:38 AM
So I got tired of deleting a program and making a new one every time I updated it on pastebin, so I tried to write a replace program.



local yes = 21
local no = 49

tArgs = {...}

fileName = tArgs[1]

pasteBinCode = tArgs[2]

local x, y = term.getCursorPos()

if (#tArgs == 2) then
term.write("Are you sure you want to overwrite " .. fileName .. "? <y/n>")
term.setCursorPos(1,(y+1))
local event, key = os.pullEvent("key")
while ((key ~= yes) and (key ~= no)) do
local event, key = os.pullEvent("key")
end
if key == yes then
shell.run("delete", fileName)
shell.run("pastebin", "get", pastebinCode, fileName)
end
else
term.write("Usage: replace <File Name> <Pastebin Code>")
term.setCursorPos(1,(y+1))
end

The problem is, I dont think im calling the pastebin function correctly, because every time I run replace, it tells me the proper usage for pastebin.

Any insight?
Goof #2
Posted 16 December 2012 - 11:42 AM
Do you get any errors ?
AstronautG117 #3
Posted 16 December 2012 - 11:48 AM
Not an error, no. But lets say I input:

replace test abc123xyz

It then says:

Are you sure you want to overwrite test? <y/n>

I hit "y" and it outputs this:

Usages:
pastebin put <filename>
pastebin get <code> <filename>
Orwell #4
Posted 16 December 2012 - 12:02 PM
You define pasteBinCode with an upper case 'B':

pasteBinCode = tArgs[2]

And then you use pastebinCode with a lower case 'b':

shell.run("pastebin", "get", pastebinCode, fileName)

AstronautG117 #5
Posted 16 December 2012 - 12:24 PM
You define pasteBinCode with an upper case 'B':

pasteBinCode = tArgs[2]

And then you use pastebinCode with a lower case 'b':

shell.run("pastebin", "get", pastebinCode, fileName)


That fixed it! Thanks!