Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local key="lipAPI.public_key"
- local id = os.getComputerID()
- local channel = 5480
- local timeout = 5
- function setTimeout(n)
- if not tonumber(n) or n<=0 then
- error("Timeout should be a positive number",2)
- exit()
- end
- timeout = math.max(.1,tonumber(n))
- end
- local function request(_p)
- local modem = peripheral.find("modem", function(name, object) return object.isWireless() end)
- if not modem then
- error("Not found: wireless modem",2)
- exit()
- end
- local data = {key,_p}
- local keepOpen = modem.isOpen(id)
- if not keepOpen then modem.open(id) end
- local _timeout = os.startTimer(timeout)
- modem.transmit(channel,id,data)
- while true do
- local e, p, to, from, result, dist = os.pullEvent()
- if e=="modem_message" and to==id and from==channel then
- if not keepOpen then modem.close(id) end
- if result[1] then
- return result[2]
- else
- error(result[2],2)
- exit()
- end
- elseif e=="timer" and p==_timeout then
- error("408 Request Timeout",2)
- exit()
- end
- end
- end
- WorldInterface = {
- getBiome = function(x,y,z) return request({"WorldInterface","getBiome",x,y,z}) end,
- getWeather = function() return request({"WorldInterface","getWeather"}) end,
- getBlockInfos = function(x,y,z) return request({"WorldInterface","getBlockInfos",x,y,z}) end,
- getBlockDatatags = function(x,y,z) return request({"WorldInterface","getBlockDatatags",x,y,z}) end,
- getRealDate = function() return request({"WorldInterface","getRealDate"}) end,
- getPlayerList = function() return request({"WorldInterface","getPlayerList"}) end,
- getMethods = function(str) if str then return request({"WorldInterface","getMethods",str}) else return request({"WorldInterface","getMethods"}) end end,
- }
- EntityDetector = {
- getEntityList = function(r,x,y,z) return request({"EntityDetector","getEntityList",r,x,y,z}) end,
- getEntityListAdvanced = function(r,x,y,z) return request({"EntityDetector","getEntityListAdvanced",r,x,y,z}) end,
- getPlayerDetail = function(name) return request({"EntityDetector","getPlayerDetail",name}) end,
- getMethods = function(str) if str then return request({"EntityDetector","getMethods",str}) else return request({"EntityDetector","getMethods"}) end end,
- }
Advertisement
Add Comment
Please, Sign In to add comment