Advertisement
SkyCrafter0

cmd.lua

Dec 2nd, 2020
1,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. local modules = peripheral.wrap("back")
  2.  
  3. local owner = "SkyCrafter0"
  4. local afk = false
  5.  
  6. modules.capture("^s/")
  7.  
  8. local function split(inputstr,sep)
  9.     sep = sep or "%s"
  10.     local t = {}
  11.     for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do table.insert(t, str) end
  12.     return t
  13. end
  14.  
  15. local function main()
  16.   while true do
  17.     local _, message, capture, player, uuid = os.pullEvent("chat_capture")
  18.     --print(player .. " said " .. message)
  19.     local cmd = split(message,"/")
  20.     local command = cmd[2]
  21.     if player == owner and command == "afk" then
  22.       if cmd[3] == "on" then
  23.         afk = true
  24.         print("AntiAFK On")
  25.         modules.tell("AntiAFK On")
  26.       elseif cmd[3] == "off" then
  27.         afk = false
  28.         print("AntiAFK Off")
  29.         modules.tell("AntiAFK Off")
  30.       end
  31.     elseif player == owner and command == "scan" then
  32.       print("Scanning for " .. cmd[3])
  33.       local tScan = modules.scan()
  34.       local oX,oY,oZ = 0,0,0
  35.       local pX,pY,pZ = gps.locate()
  36.       for i=1, #tScan do
  37.         if tScan[i].name == cmd[3] then
  38.           oX,oY,oZ = tScan[i].x,tScan[i].y,tScan[i].z
  39.         end
  40.       end
  41.       print("Local offset: ", oX,oY,oZ)
  42.       local rX,rY,rZ = pX+oX,pY+oY,pZ+oZ
  43.       if rX == pX and rY == pY and rZ == pZ then
  44.         modules.tell("Block not found")
  45.         print("Block not found")
  46.       else
  47.         modules.tell("The block is at " .. tostring(rX) .. ", " .. tostring(rY) .. ", " .. tostring(rZ))
  48.         print("Real Location: ", rX,rY,rZ)
  49.     end
  50.   end
  51. end
  52.  
  53. function doJump()
  54.   while true do
  55.     if afk then
  56.         modules.launch(0,-90,4)
  57.     end
  58.     sleep(120)
  59.   end
  60. end
  61.  
  62. parallel.waitForAny(main,doJump)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement