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

[Lua] [Error] Http Api

Started by justync7, 12 April 2012 - 01:12 AM
justync7 #1
Posted 12 April 2012 - 03:12 AM
So, I am trying to create a program that gets the http from http://www.tiny.cc/lolosver but i keep getting a "attempt to index ? (a nil value)"
anyone know how? Thanks if you can.
Luanub #2
Posted 12 April 2012 - 03:14 AM
Code? Hard to find whats wrong without it.


Read this… http://www.computercraft.info/forums2/index.php?/topic/475-get-help-faster-read-me/
djblocksaway #3
Posted 12 April 2012 - 08:35 AM
yeah we cant really help you if there is no code to look at (the only thing we can really do is tell u what the error means!?)
Kolpa #4
Posted 12 April 2012 - 12:11 PM
well what u can do is the following thing :P/>/>

local file = http.get("http://www.tiny.cc/lolosver")
local ver = file:readAll()

the var ver shoud be all the webpage content :D/>/>

but i dont know if tiny.cc is the problem :)/>/>
Mads #5
Posted 12 April 2012 - 12:50 PM
You probably don't have the http API on. go to .minecraftconfigmod_ComputerCraft.cfg, and change "enableAPI_http=0" to "enableAPI_http=1"
justync7 #6
Posted 12 April 2012 - 11:22 PM
Http API Enabled And What I Wanted Was A Explanation Of How It Works. Like Kolpa Did.
EDIT: @Kolpa Using That Code And Adding Only print(ver) I still get test:1:Attempt to index ? (a nil value)
Kolpa #7
Posted 13 April 2012 - 07:28 PM
well like i said try to not use the tiny.cc link use the real one so like this:
local file = http.get("http://dl.dropbox.com/u/50273341/version.http")
local ver = file:readAll()
or rename it to .html
:P/>/>
kamnxt #8
Posted 13 April 2012 - 09:35 PM
well like i said try to not use the tiny.cc link use the real one so like this:
local file = http.get("http://dl.dropbox.com/u/50273341/version.http")
local ver = file:readAll()
or rename it to .html
:P/>/>
Or txt :D/>/>
Kolpa #9
Posted 13 April 2012 - 10:30 PM
well like i said try to not use the tiny.cc link use the real one so like this:
local file = http.get("http://dl.dropbox.com/u/50273341/version.http")
local ver = file:readAll()
or rename it to .html
:P/>/>
Or txt :D/>/>
well i dont now cuz its made for reading websites so i thought html woud be better :)/>/>
kamnxt #10
Posted 14 April 2012 - 09:22 AM
well like i said try to not use the tiny.cc link use the real one so like this:
local file = http.get("http://dl.dropbox.com/u/50273341/version.http")
local ver = file:readAll()
or rename it to .html
:P/>/>
Or txt :D/>/>
well i dont now cuz its made for reading websites so i thought html woud be better :)/>/>
Well… I got it to read txts from my website and DCPU16 specifications from 0x10c. :)/>/>
Kolpa #11
Posted 14 April 2012 - 12:45 PM
well like i said try to not use the tiny.cc link use the real one so like this:
local file = http.get("http://dl.dropbox.com/u/50273341/version.http")
local ver = file:readAll()
or rename it to .html
:)/>/>
Or txt :)/>/>
well i dont now cuz its made for reading websites so i thought html woud be better :)/>/>
Well… I got it to read txts from my website and DCPU16 specifications from 0x10c. :)/>/>

well then :)/>/>

well like i said try to not use the tiny.cc link use the real one so like this:
local file = http.get("http://dl.dropbox.com/u/50273341/version.http")
local ver = file:readAll()
or rename it to .html
:)/>/>
btw woudnt use dropox for this cuz u cant change the file with the link
Kolpa #12
Posted 14 April 2012 - 12:50 PM
i can code u a php/mysql db ver tool and give u some webspace if u want :)/>/>

local file = http.get("http://mastersofarms.no-ip.org/ver.php")
local ver = file:readAll() print(ver)
gonna code a vb ver changer and pm it to u if interested :)/>/>
okay all set pm me and u get it :)/>/>
and yes it works :)/>/> tested
Edited on 14 April 2012 - 11:45 AM