View Full Version : How do I account for a computer being offline in socket.http.request?

May 26th, 2016, 04:43 AM
Never mind, found a way:

if http.request("") == nil
print ("Nothing here")
print ("Here we are")

I have this code to check if JRMC is playing:

local _, _, PlayMode = string.find(socket.http.request('' .. SoneVariable .. '&ZoneType=Index'), 'State">(%d+)<')

The problem comes when the computer it checks is offline, or JRMC has exited with an error, or something like that. It doesn't happen often (maybe every third month or so), but I would like to have a check for that, but I get:

bad argument #1 to `find' (string expected, got nil)

So is there any way to check if JRMC is offline and have a new action happen in that cas? I can create the action, so let's just say:

print("JRMC is offline")

And if it's online just continue the script as usual.