Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("/crypt_wper") then
- local httpPastebin = http.get("http://pastebin.com/raw/afktfgQ0")
- local httpPastebinData = httpPastebin.readAll()
- httpPastebin.close()
- local fileData = fs.open("/crypt_wper", "w")
- fileData.write(httpPastebinData)
- fileData.close()
- end
- if not pocket then
- error("This API is made for Wireless Pocket Computer")
- end
- if not peripheral.find("modem") then
- error("This API require a wireless modem")
- end
- os.loadAPI("crypt_wper")
- local sSendKey = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTkFEQ0JpUUtCZ1FEckJlOHU1K1B5MVVKdDRka3JRdnBicEM0aAp1dG01OURJeDNETGxHM3ZPSGpTY1RaYXdZVXhsQ1lsTjRpd2k1eGpmS1NXU1Y4YlFZSHJYMVJVWWN3VXdXdlZBCklzak9remthZmtkYml5NjU0bWdad1R2SFFIUXhqODZCZVhUU0JGNmt6L3M2RSsyTGlXM0JRSnRKVHpPdjUwQWcKdVEzclA4Mnhkb2Z1QytYRjJRSURBUUFCCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo"
- local sReceiveKey = "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUNkZ0lCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQW1Bd2dnSmNBZ0VBQW9HQkFLeGxMbXh5MitkRW1wVXEKVVo1eFN2cUFzeEtmdk9MLzZvWUJqQ2tMdjdUNFRacnZZRExxYUFCcDZaWWVKenFOZTZNRGxUd0xnbnNRbVJxegpYQXBqVGZ4TURLaFlLWkhoTStwRzZ2NWJHdE5iR3E0cllodDFMR05nR3VNZVZjS3pkd0JJaFpOdE5LWlBGK2RVCm1zVGJyQWtRRWx5V05ZVENzQ3phUjVDTEpFME5BZ01CQUFFQ2dZQmNKWUVZNnBQc0c5bGNuZEFlbG9QelBkTjUKd3ZRZGlaajdvOXdkSEhDTjlLTFdpOWlwbm0yVXV3ZmwrNXdRU2d1cDZJSmVJL0RNZ3VTelJ1ZU5qZUxpZGRiMwpLQWE4c0tYS0wvaGIvUUlNMFVWeHMyc0MwUHVMQ2VMenQ5RlR3ZUtxbVdGQkE4NThhMW16RHk0eVhENjIvbWtLCllwZ2I5TlA1bzc5Z201V1dnUUpCQU5LVGRZbDg5WmZqV2txMWxFT3BRaWRyd0psMnlLaS9ZdEZuZTNnUDExS1oKS2d4TWNDeS9xSFpWTysxUS9mbHdGdzZJTlBsMlNKZ201bUNwQWNMai9wRUNRUURSbFVpQlFQekJ1NWJ4dGRpTQp0VFltSGlKbWs5U0FXTDZDL2xDall0a0RBNHJ1M0k2S1dFRTZWaFYrc2FSUVJUOG42QkpWZ1RyUWk3WjNHUlRaCklaeTlBa0JCKytNQXloOUxFUHJpSGpQdlg4SlRCL2k2SGZhU3FpWVU2QkJRZHVaS0E2U2haZkpnazAzK2hvYlkKdm1CWElVQ1lWU1lFWllRcDZVYVhVMTR4NjYrQkFrQWk2eE5jYlo1dkRMa1dabXpBN01Rcno2TjlvYTJyQUo0bApKd2Y2WU5LMVBOYmQreU5JaTNHNnJYTUJXOGw3a2ozMmdTVGsyQlliZnR1VXRqb1IveGFsQWtFQXU3eUpKR1NzClI2djRKWWtlVlFEYTEzUVQxaDcwNytYK1RFYUNwTm1mSllUL0g4ZlZOZjZFUDRYbXFNQ0wvbEh5MW5VT3cydDMKZ3VUR1V2TC8zR2F6VVE9PQotLS0tLUVORCBQUklWQVRFIEtFWS0tLS0tCg"
- worldInterface = {}
- entityDetector = {}
- chatInterface = {}
- local function sendMessage(sPeripheral, sMethod, tArgs)
- local m = peripheral.find("modem")
- tArgs = tArgs or {}
- m.transmit(60300, os.getComputerID(), crypt_wper.encrypt(textutils.serialise({peripheral = sPeripheral, method = sMethod, arguments = tArgs}), sSendKey))
- return true
- end
- local function receiveMessage()
- local m = peripheral.find("modem")
- m.open(os.getComputerID())
- local nTimeout = os.startTimer(5)
- while true do
- local event, p1, p2, p3, p4, p5 = os.pullEvent()
- if event == "modem_message" and p3 == 60300 then
- m.close(os.getComputerID())
- message = crypt_wper.decrypt(p4, sReceiveKey)
- os.cancelTimer(nTimeout)
- if type(message) == "string" and message:sub(1, 12) == "serverError:" then
- return false, message:sub(13, string.len(message))
- else
- return message
- end
- elseif event == "timer" and p1 == nTimeout then
- return false, "Timeout error"
- end
- end
- end
- function worldInterface.getBiome(...)
- sendMessage("WorldInterface", "getBiome", {...})
- return receiveMessage()
- end
- function worldInterface.getWeather(...)
- sendMessage("WorldInterface", "getWeather", {...})
- return receiveMessage()
- end
- function worldInterface.getBlockInfos(...)
- if #{...} < 3 then
- return false, "getBlockInfos(X,Y,Z)"
- end
- sendMessage("WorldInterface", "getBlockInfos", {...})
- return receiveMessage()
- end
- function worldInterface.getBlockDatatags(...)
- if #{...} < 3 then
- return false, "getBlockDatatags(X,Y,Z)"
- end
- sendMessage("WorldInterface", "getBlockDatatags", {...})
- return receiveMessage()
- end
- function worldInterface.getRealDate(...)
- sendMessage("WorldInterface", "getRealDate", {...})
- return receiveMessage()
- end
- function worldInterface.getPlayerList(...)
- sendMessage("WorldInterface", "getPlayerList", {...})
- return receiveMessage()
- end
- function worldInterface.getMethods(...)
- return {"getBiome", "getWeather", "getBlockInfos", "getBlockDatatags", "getRealDate", "getPlayerList", "getMethods", "scanRegion", "getColor", "rawLaunch"}
- end
- function worldInterface.scanRegion(...)
- if #{...} < 6 then
- return false, "scanRegion(X,Y,Z,dX,dY,dZ)"
- end
- sendMessage("WorldInterface", "scanRegion", {...})
- return receiveMessage()
- end
- function worldInterface.getColor(...)
- if #{...} < 3 then
- return false, "getColor(X,Y,Z)"
- end
- sendMessage("WorldInterface", "getColor", {...})
- return receiveMessage()
- end
- function worldInterface.rawLaunch(sMethod, ...)
- if not sMethod then
- return false, "rawLaunch(Method, ...)"
- end
- sendMessage("WorldInterface", sMethod, {...})
- return receiveMessage()
- end
- function entityDetector.getEntityListAdvanced(...)
- if #{...} < 4 then
- return false, "getEntityListAdvanced(Range,[X],[Y],[Z])"
- end
- sendMessage("EntityDetector", "getEntityListAdvanced", {...})
- return receiveMessage()
- end
- function entityDetector.getEntityList(...)
- if #{...} < 4 then
- return false, "getEntityList(Range,[X],[Y],[Z])"
- end
- sendMessage("EntityDetector", "getEntityList", {...})
- return receiveMessage()
- end
- function entityDetector.getPlayerDetail(...)
- if #{...} < 1 then
- return false, "getPlayerDetail(PlayerName)"
- end
- sendMessage("EntityDetector", "getPlayerDetail", {...})
- return receiveMessage()
- end
- function entityDetector.getMethods(...)
- return {"getEntityListAdvanced", "getEntityList", "getPlayerDetail", "getMethods", "rawLaunch"}
- end
- function entityDetector.rawLaunch(sMethod, ...)
- if not sMethod then
- return false, "rawLaunch(Method, ...)"
- end
- sendMessage("EntityDetector", sMethod, {...})
- return receiveMessage()
- end
- function chatInterface.sendGlobalMessage(...)
- if #{...} < 1 then
- return false, "sendGlobalMessage(Message)"
- end
- sendMessage("ChatInterface", "sendGlobalMessage", {...})
- return receiveMessage()
- end
- function chatInterface.sendPlayerMessage(...)
- if #{...} < 2 then
- return false, "sendPlayerMessage(Player, Message)"
- end
- sendMessage("ChatInterface", "sendPlayerMessage", {...})
- return receiveMessage()
- end
- function chatInterface.setName(...)
- if #{...} < 1 then
- return false, "setName(Name)"
- end
- sendMessage("ChatInterface", "setName", {...})
- return receiveMessage()
- end
- function chatInterface.getName(...)
- sendMessage("ChatInterface", "getName", {...})
- return receiveMessage()
- end
- function chatInterface.getMethods(...)
- return {"sendGlobalMessage", "sendPlayerMessage", "setName", "getName", "getMethods", "rawLaunch"}
- end
- function chatInterface.rawLaunch(sMethod, ...)
- if not sMethod then
- return false, "rawLaunch(Method, ...)"
- end
- sendMessage("ChatInterface", sMethod, {...})
- return receiveMessage()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement