Advertisement
Andronio12

Remote Drone Controller BIOS (WIP) [OpenComputers]

Apr 12th, 2017
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local tr_port = 22866 -- Порт передатчика(это устройсто)
  2. local rc_port = 53646 -- Порт приемника
  3. local mod_st = 8 -- Изначальная сила модема
  4. local slot_selected = 1
  5.  
  6. local m = component.proxy(component.list('modem')())
  7. local drone = component.proxy(component.list("drone")())
  8. drone.select(slot_selected)
  9.  
  10. if not m.open(tr_port) and not m.isOpen(tr_port) then
  11.   error('Не удалось открыть порт '..tr_port)
  12. end
  13.  
  14. m.setWakeMessage('Power On!')
  15. m.setStrength(mod_st)
  16.  
  17. function send(...)
  18.   m.broadcast(rc_port,...)
  19. end
  20. local invsize = drone.inventorySize()
  21.  
  22. while true do
  23.   local a = {computer.pullSignal(0.5)}
  24.   if a[1] == 'modem_message' then
  25.     if a[6] == 'Accel' then
  26.       drone.setAcceleration(a[7])
  27.     elseif a[6] == 'Slot' then
  28.       slot_selected = a[7]
  29.       drone.select(slot_selected)
  30.     elseif a[6] == 'Streng' then
  31.       m.setStrength(a[7])
  32.     elseif a[6] == 'move' then
  33.       drone.move(a[7],a[8],a[9])
  34.     elseif a[6] == 'Power Off!' then
  35.       computer.shutdown(false)
  36.     end
  37.   end
  38.   local comp_eng = math.floor(computer.energy()/computer.maxEnergy()*100 + 0.5)
  39.   local accel = drone.getAcceleration()
  40.   local stack_in_slot = drone.count()
  41.   local mod_st = m.getStrength()
  42.   send('Info',comp_eng,accel,invsize,slot_selected,stack_in_slot,mod_st)
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement