rollton

прошивка на EEPROM для интерпретатора (OpenComputers)

Sep 17th, 2017
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local components = "\n"
  2. for add, mod in component.list() do components = components..'  '..add..'  '..mod..'\n' if mod ~= 'computer' then pcall(load(mod..' = component.proxy(component.list(\"'..mod..'\")())')) end end
  3.  
  4. if modem ~= nil then modem.open(port) broadcast = modem.broadcast modem.setWakeMessage('_start') else if tunnel == nil then computer.beep(1000,0.5) computer.shutdown() end modem = {} end
  5. function send(a,b) if broadcast ~= nil then broadcast(a,b) else tunnel.send(b) end end
  6.  
  7. function os.sleep(time) local e = {computer.pullSignal(time)} if e[1] == "modem_message" and e[6] == 'exit' then os.exit() end end
  8. while true do
  9.     local e = {computer.pullSignal(1)}
  10.     if (e[1] == "modem_message") and (e[6] ~= nil) then
  11.         local aa,bb = e[6]:find("components")
  12.         if aa ~= nil and aa < 4 then
  13.             txt = "\n"
  14.             if pcall(load('for a,b in pairs('..e[6]:sub(bb+2)..') do txt = txt.."  "..a.."(..):"..type(b):gsub("function","func")..",\\n" end')) then
  15.                 send(port+1,txt:gsub(",","")..'\n '..txt:gsub("\n ",""):gsub("%.%.",""))
  16.             else
  17.                 send(port+1,components)
  18.             end
  19.             aa,bb,txt = nil
  20.         else
  21.             local runProgramma = e[6]
  22.             while tostring(e[7]) == '_echo' do
  23.                 e = {computer.pullSignal(1)}
  24.                 if tostring(e[1]) == "modem_message" then runProgramma = runProgramma..e[6] end
  25.             end
  26.  
  27.             local _,errorText = pcall(load(runProgramma))
  28.             if errorText ~= nil then
  29.                 if drone ~= nil then
  30.                     oldColor = drone.getLightColor()
  31.                     drone.setLightColor(0xff0000)
  32.                 end
  33.                 send(port+1," Error: "..errorText)
  34.                 computer.beep(1000,0.5)
  35.                 if drone ~= nil then drone.setLightColor(oldColor) end
  36.             else
  37.                 send(port+1,nil)
  38.             end
  39.         end
  40.     end
  41. end
RAW Paste Data