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

Odd idea Wanting to know if its Do-able

Started by RustyDagger, 18 April 2014 - 03:39 AM
RustyDagger #1
Posted 18 April 2014 - 05:39 AM
Back Story: (reason for this )
I am playing a DW20 FTB server and I Have a spot loader in my house there are some builds in the chunk that Do not need to be running when one of the players from our group are not online so I need some way to get a list of online players to base some logic on to turn Builds on and off to prevent server lag.

Question:

Is it Possibal to use the http Api to some how use this webpage to return me a list of Online players for the server.

If so where would be the best place to start looking iv already looked at the wiki for the http api and it left me a little confused.
KingofGamesYami #2
Posted 18 April 2014 - 07:58 AM
You can download the contents of the webpage like this:

local response = http.get("http://www.atrminecraft.enjin.com/home") --#get response
if response then
 local sResponse = response.readAll() --#set sResponse to the webpage's data
 response.close()
 file = fs.open("atrminecraft", "w") --#open a new file "atrminecraft"
 file.write(sResponse) --#save the webpage data to "atrminecraft"
 file.close()
else
 error("Can't connect to atrminecraft!") --#if computer cannot reach website
end
But I can't make (much) sense of the HTML formatting. It also seems to be locked in some way, as I cannot open the file in TextEdit (I'm on a mac) The whole file is 1 line, and idk how long that line is… Makes it really hard to figure out what you're looking at.
Edited on 18 April 2014 - 02:50 PM
RustyDagger #3
Posted 19 April 2014 - 12:43 AM
thank you! I will see what I can do from there Im sure i can do something but first things first get me a copy of that file and try and take a look at it. manipulating it could be troubblsome :0