csmit195

Dragon farm when no players

Sep 25th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. function init()
  2.   while true do
  3.     rs.setOutput('back', rs.getInput('top'))
  4.     if ( not rs.getInput('top') ) then
  5.         local headers = {
  6.             ['User-Agent'] = 'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36'
  7.         }
  8.         local response = http.get('http://mcapi.xdefcon.com/server/ie.toastynetworks.net/players/text', headers)
  9.         local currentPlayers = response.readAll()
  10.         local responseCode = response.getResponseCode()
  11.         if ( tonumber(currentPlayers) == 0 ) then
  12.             rs.setOutput('back', true)
  13.         else
  14.             rs.setOutput('back', false)
  15.         end
  16.         response.close()
  17.       end
  18.     sleep(5)
  19.   end
  20. end
  21.  
  22. function safeString(text)
  23.   local newText = {}
  24.   for i = 1, #text do
  25.       local val = text:byte(i)
  26.       newText[i] = (val > 31 and val < 127) and val or 63
  27.   end
  28.   return string.char(unpack(newText))
  29. end
  30.  
  31. init()
Advertisement
Add Comment
Please, Sign In to add comment