58 posts
Location
Seattle
Posted 04 March 2013 - 10:15 AM
I have no idea…
bios:338: [string "paste"]:6: '=' expected
local tArgs = { ... }
local sCode = tArgs[1]
local sFile = tArgs[2]
local sPath = shell.resolve( sFile )
local response = http.get("http://pastebin.com/raw.php?i=" ..sCode)
if response then
failed = false
local sResponse = response.readAll()
response.close()
local file = fs.open( sPath, "w" )
file.write( sResponse )
file.close()
print( "Downloaded as "..sFile )
else
print( "Failed." )
failed = true
fail()
end
failed and fail are already created in the startup program btw
Thanks in advance wonderful forum members
671 posts
Location
That place over there. Y'know. The one where I am.
Posted 04 March 2013 - 10:21 AM
Have you got the HTTP API as true in your config? That's the only explanation I can think of. It's off by default so you have to turn it on manually. Go into:
%appdata%/.minecraft/config/ComputerCraft.cfg
and there should be a line with:
# Enable the "http" API on Computers
B:enableAPI_http=false
Set the 'false' to true and it should work.
1511 posts
Location
Pennsylvania
Posted 04 March 2013 - 01:51 PM
You could also add a check to ensure http is enabled like so:
if not http then
return error("Http is not enabled!")
end
Pretty nice in some occasions.
Also, why are you making a pastebin program when CC already has one?
7508 posts
Location
Australia
Posted 04 March 2013 - 02:03 PM
Also, why are you making a pastebin program when CC already has one?
Have you seen my "Program d" … it was my first http program, its a good starting point … just like door locks are the starting point of anything else …
1511 posts
Location
Pennsylvania
Posted 04 March 2013 - 04:06 PM
Also, why are you making a pastebin program when CC already has one?
Have you seen my "Program d" … it was my first http program, its a good starting point … just like door locks are the starting point of anything else …
Hmm, I guess you are right. ( Like the program btw :P/> )
Side Note:You seem to counter everything I have to say! Let the games begin :D/> (Even though challenging a Semi-Professional ComputerCrafter would call for the highest degree of sorcery)
997 posts
Location
Wellington, New Zealand
Posted 04 March 2013 - 05:20 PM
This error message would NOT be caused by HTTP being disabled. I'm on my phone so I can't see the code to tell you the real problem.
1511 posts
Location
Pennsylvania
Posted 04 March 2013 - 05:35 PM
This error message would NOT be caused by HTTP being disabled. I'm on my phone so I can't see the code to tell you the real problem.
It seems to be erroring at line 6 which is where he defines the variable "response" The following is the exact same code as he posted, line for line.
local tArgs = { … }
local sCode = tArgs[1]
local sFile = tArgs[2]
local sPath = shell.resolve( sFile )
local response = http.get("
http://pastebin.com/raw.php?i=" ..sCode)
if response then
failed = false
local sResponse = response.readAll()
response.close()
local file = fs.open( sPath, "w" )
file.write( sResponse )
file.close()
print( "Downloaded as "..sFile )
else
print( "Failed." )
failed = true
fail()
end
997 posts
Location
Wellington, New Zealand
Posted 04 March 2013 - 08:04 PM
With http:
paste:21: attempt to call nil
Without http:
paste:6: attempt to index '?' (a nil value)
Conclusion: The code in the OP is different from the code he was actually trying to run.
1619 posts
Posted 04 March 2013 - 08:06 PM
In-game: type "pastebin put [filename]"
As immibis said, you copied the code wrong.
1522 posts
Location
The Netherlands
Posted 05 March 2013 - 06:41 AM
do you have the function fail defined?
if not, then you should this above your code
function fail()
-- What you want to do
end
But as I am typing this, dont you want to use error()? If this has been run directly from the shell, then you wont need the error() or fail() except if you want to do something else with fail()
I hope I've helped you,
Engineer
58 posts
Location
Seattle
Posted 05 March 2013 - 07:03 AM
Hmm, it works now. Creepy.
Edit: Someone was messing with me on my server -_-/>