Скрипт управления джампдрайвом

  1. local command_table = {
  2. {command = "clear"},
  3. {command = "set", width = 10, height = 7},
  4. {command = "addbutton", X = 0.2,Y = 1.3,W = 3,H = 2,name = "btn_cirhe",label = "Часовня"},
  5. {command = "addbutton", X = 0.2,Y = 2.7,W = 3,H = 2,name = "btn_spawn",label = "Спавн"},
  6. {command = "addbutton", X = 0.2,Y = 3.4,W = 3,H = 2,name = "btn_1",label = "Светлячки"},
  7. {command = "addbutton", X = 0.2,Y = 4.1,W = 3,H = 2,name = "btn_island",label = "Острова летающие"},
  8. {command = "addbutton", X = 0.2,Y = 4.8,W = 3,H = 2,name = "btn_ohota",label = "ОХОТА"},
  9. {command = "addbutton", X = 4,Y = 1.3,W = 3,H = 2,name = "btn_planet",label = "ПЛАНЕТА"},
  10. {command = "addbox", X = 7,Y = 6.15,W = 2,H = 1,color = "red"},
  11. {command = "addbutton_exit", X = 0.2,Y = 6,W = 3,H = 2,name = "btn_jump",label = "ПРЫЖОК"}
  12. }
  13.  
  14. function set_screen_draw(info_text, var_mainship)
  15. table.insert(command_table, {command = "addtextarea", X = 0.3, Y = 0.1,W = 10, H = 2,name = "terminal", label ="Монитор данных", default = info_text})
  16. if var_mainship == true then
  17. table.insert(command_table, {command = "addbutton", X = 0.2,Y = 2,W = 3,H = 2,name = "btn_home",label = "Дом"})
  18. table.insert(command_table, {command = "addcheckbox", X = 7.2,Y = 6,name = "mainship",label = "КОРАБЛЬ",selected = "true"})
  19. table.insert(command_table, {command = "addcheckbox", X = 7.2,Y = 6.5,name = "smallship",label = "ЧЕЛНОК",selected = "false"})
  20. elseif var_mainship == false then
  21. table.insert(command_table, {command = "addbutton", X = 0.2,Y = 2,W = 3,H = 2,name = "s_btn_home",label = "Дом"})
  22. table.insert(command_table, {command = "addcheckbox", X = 7.2,Y = 6,name = "mainship",label = "КОРАБЛЬ",selected = "false"})
  23. table.insert(command_table, {command = "addcheckbox", X = 7.2,Y = 6.5,name = "smallship",label = "ЧЕЛНОК",selected = "true"})
  24. end
  25. digiline_send("touchscreen", command_table)
  26. end
  27.  
  28. if event.type == "digiline" and event.channel == "jumpdrive" then
  29. if event.msg.powerstorage ~= nil then
  30. init_data = "Энергия: " .. tostring(event.msg.powerstorage) .. "\nТекущая позиция: Х=" .. event.msg.position.x .. ", У=" .. event.msg.position.y .. ", Z=" .. event.msg.position.z .. "\nЦель: Х=" .. event.msg.target.x .. ", У=" .. event.msg.target.y .. ", Z=" .. event.msg.target.z .. "\nРадиус поля захвата: " .. tostring(event.msg.radius) .. "\nДистанция прыжка в метрах: " .. tostring(event.msg.distance) .. "\nЭнергии требуется: " .. tostring(event.msg.power_req)
  31. elseif event.msg.success ~= nil then
  32. init_data = "Результат: " .. tostring(event.msg.success) .. "\nВремя в микросекундах: " .. tostring(event.msg.time)
  33. end
  34.  
  35. if event.msg.radius == 5 then
  36. set_screen_draw(init_data, true)
  37. else
  38. set_screen_draw(init_data, false)
  39. end
  40. end
  41.  
  42. if event.type == "program" then
  43. --Рисуем кнопки 1 при программировании контроллера
  44. set_screen_draw("Старт////... Укажите радиус поля захвата...]", true)
  45. elseif event.msg.btn_cirhe then
  46. digiline_send("jumpdrive", {command = "set", x = 193, y = 29, z = 238, formupdate = true })
  47. digiline_send("jumpdrive", {command = "get"})
  48. elseif event.msg.btn_home then
  49. digiline_send("jumpdrive", {command = "set", x = -769, y = 80, z = 955, formupdate = true })
  50. digiline_send("jumpdrive", {command = "get"})
  51. elseif event.msg.s_btn_home then
  52. digiline_send("jumpdrive", {command = "set", x = -769, y = 80, z = 959, formupdate = true })
  53. digiline_send("jumpdrive", {command = "get"})
  54. elseif event.msg.btn_spawn then
  55. digiline_send("jumpdrive", {command = "set", x = 3000, y = 35, z = 300, formupdate = true })
  56. digiline_send("jumpdrive", {command = "get"})
  57. elseif event.msg.btn_1 then
  58. digiline_send("jumpdrive", {command = "set", x = 2260, y = 25, z = 50, formupdate = true })
  59. digiline_send("jumpdrive", {command = "get"})
  60. elseif event.msg.btn_island then
  61. digiline_send("jumpdrive", {command = "set", x = -4750, y = 1859, z = 985, formupdate = true })
  62. digiline_send("jumpdrive", {command = "get"})
  63. --set_screen_draw(event.msg.clicker, var_mainship)
  64. elseif event.msg.btn_ohota then
  65. digiline_send("jumpdrive", {command = "set", x = 3434, y = 1850, z = 2323, formupdate = true })
  66. digiline_send("jumpdrive", {command = "get"})
  67. elseif event.msg.btn_planet then
  68. digiline_send("jumpdrive", {command = "set", x = 9000, y = 9070, z = 4200, formupdate = true })
  69. digiline_send("jumpdrive", {command = "get"})
  70. elseif event.msg.btn_jump then
  71. digiline_send("jumpdrive", {command = "jump"})
  72. elseif event.msg.mainship then
  73. set_screen_draw("Задан радиус 5 - режим главный корабль.", true)
  74. digiline_send("jumpdrive", {command = "set", r = 5, formupdate = true })
  75. elseif event.msg.smallship then
  76. set_screen_draw("Задан радиус 1 - режим спасательный челнок.", false)
  77. digiline_send("jumpdrive", {command = "set", r = 1, formupdate = true })
  78. end
21:46
Нет комментариев. Ваш будет первым!
Посещая этот сайт, вы соглашаетесь с тем, что мы используем файлы cookie.