Advertisement
SkyCrafter0

[Plethora-NI] cmd.lua

Dec 8th, 2020 (edited)
907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | None | 0 0
  1. local modules = peripheral.wrap("back")
  2.  
  3. local tVar = {}
  4.  
  5. tVar.owner = "SkyCrafter0"
  6. tVar.afk = false
  7.  
  8. modules.capture("^s/")
  9.  
  10. local function split(inputstr,sep)
  11.     sep = sep or "%s"
  12.     local t = {}
  13.     for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do table.insert(t, str) end
  14.     return t
  15. end
  16.  
  17. local function contains(t, value)
  18.   for i = 1, #t do
  19.     if t[i] == value then
  20.       return true
  21.     end
  22.   end
  23.   return false
  24. end
  25.  
  26. local function main()
  27.   while true do
  28.     local _, message, capture, player, uuid = os.pullEvent("chat_capture")
  29.     --print(player .. " said " .. message)
  30.     local cmd = split(message,"/")
  31.     local command = cmd[2]
  32.     if player == tVar.owner and command == "afk" then
  33.       if cmd[3] == "on" then
  34.         tVar.afk = true
  35.         print("AntiAFK On")
  36.         modules.tell("AntiAFK On")
  37.       elseif cmd[3] == "off" then
  38.         tVar.afk = false
  39.         print("AntiAFK Off")
  40.         modules.tell("AntiAFK Off")
  41.       end
  42.     elseif player == tVar.owner and command == "scan" then
  43.       print("Scanning for " .. cmd[3])
  44.       local tScan = modules.scan()
  45.       local oX,oY,oZ = 0,0,0
  46.       local pX,pY,pZ = gps.locate()
  47.       for i=1, #tScan do
  48.         if tScan[i].name == cmd[3] then
  49.           oX,oY,oZ = tScan[i].x,tScan[i].y,tScan[i].z
  50.         end
  51.       end
  52.       print("Local offset: ", oX,oY,oZ)
  53.       local rX,rY,rZ = pX+oX,pY+oY,pZ+oZ
  54.          if rX == pX and rY == pY and rZ == pZ then
  55.          modules.tell("Block not found")
  56.               print("Block not found")
  57.          else
  58.               modules.tell("The block is at " .. tostring(rX) .. ", " .. tostring(rY) .. ", " .. tostring(rZ))
  59.               print("Real Location: ", rX,rY,rZ)
  60.       end
  61.     elseif player == tVar.owner and command == "view" then
  62.       if tVar[cmd[3]] ~= nil then
  63.         local var = tVar[cmd[3]]
  64.         print("Variable " .. cmd[3])
  65.         modules.tell("Variable " .. tostring(var))
  66.         print("Type: " .. type(var))
  67.         modules.tell("Type: " .. type(var))
  68.         if type(var) == "bool" then
  69.           print("State: " .. tostring(var))
  70.           modules.tell("State: " .. tostring(var))
  71.         elseif type(var) == "string" then
  72.           print("Contents: " .. tostring(var))
  73.           modules.tell("Contents: " .. tostring(var))
  74.         elseif type(var) == "number" then
  75.           print("Value: " .. tostring(var))
  76.           modules.tell("Value: " .. tostring(var))
  77.         elseif type(var) == "table" then
  78.           print("Contents: <NO_TBL_PRINT>")
  79.           modules.tell("Contents:")
  80.           local contents = textutils.serialise(var)
  81.           modules.tell(contents)
  82.         end
  83.       else
  84.         print("Variable not found")
  85.         modules.tell("Variable not found")
  86.       end
  87.     end
  88.   end
  89. end
  90.  
  91. local function doJump()
  92.   while true do
  93.     if tVar.afk then
  94.         modules.launch(0,-90,4)
  95.     end
  96.     sleep(120)
  97.   end
  98. end
  99.  
  100. parallel.waitForAny(main,doJump)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement