DorianH935

Untitled

Jan 29th, 2026
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.85 KB | None | 0 0
  1. --HELP: OpenGlasses 2 AR Control Suite - Full control of AR glasses features. Usage: GLASSES
  2.  
  3. -- OpenGlasses 2 AR Control Suite for M-DOS
  4. -- Supports all OpenGlasses 2 features including widgets, 3D objects, radar, and navigation
  5.  
  6. local running = true
  7. local glasses = nil
  8. local currentMenu = "main"
  9. local widgetList = {}
  10. local objectList = {}
  11. local radarPlayers = {}
  12.  
  13. -- Colors
  14. local WHITE = 0xFFFFFF
  15. local CYAN = 0x00FFFF
  16. local GREEN = 0x00FF00
  17. local YELLOW = 0xFFFF00
  18. local RED = 0xFF0000
  19. local BLUE = 0x0000FF
  20. local GRAY = 0x808080
  21.  
  22. -- Initialize glasses component
  23. local function initGlasses()
  24. local component = require("component")
  25. if component.isAvailable("glasses") then
  26. glasses = component.glasses
  27. return true
  28. end
  29. return false
  30. end
  31.  
  32. -- Clear screen and draw header
  33. local function drawHeader(title)
  34. os.display.clear()
  35. os.display.setForeground(CYAN)
  36. print("╔════════════════════════════════════════════════════════════════════╗")
  37. print("║ OpenGlasses 2 AR Control Suite v1.0 ║")
  38. print("╚════════════════════════════════════════════════════════════════════╝")
  39. os.display.setForeground(YELLOW)
  40. print("\n" .. title)
  41. os.display.setForeground(WHITE)
  42. print(string.rep("─", 70) .. "\n")
  43. end
  44.  
  45. -- Main Menu
  46. local function showMainMenu()
  47. drawHeader("Main Menu")
  48. print("1. Widget Manager")
  49. print("2. 3D Object Manager")
  50. print("3. Surface Manager")
  51. print("4. Radar Controls")
  52. print("5. Navigation System")
  53. print("6. Quick Actions")
  54. print("7. Settings & Info")
  55. print("8. Clear All Objects")
  56. print("9. Exit")
  57. print("\nSelect option (1-9): ")
  58. end
  59.  
  60. -- Widget Manager Menu
  61. local function showWidgetMenu()
  62. drawHeader("Widget Manager")
  63. print("1. Add Text Widget")
  64. print("2. Add Item Icon Widget")
  65. print("3. Add Fluid/Energy Bar Widget")
  66. print("4. Add Dotted Line")
  67. print("5. Add Rectangle/Frame")
  68. print("6. List All Widgets")
  69. print("7. Remove Widget")
  70. print("8. Back to Main Menu")
  71. print("\nSelect option (1-8): ")
  72. end
  73.  
  74. -- 3D Object Manager Menu
  75. local function show3DMenu()
  76. drawHeader("3D Object Manager")
  77. print("1. Add Cube")
  78. print("2. Add Quad (Flat Rectangle)")
  79. print("3. Add Triangle")
  80. print("4. Add Line (3D)")
  81. print("5. Add Point Cloud")
  82. print("6. List All 3D Objects")
  83. print("7. Remove 3D Object")
  84. print("8. Back to Main Menu")
  85. print("\nSelect option (1-8): ")
  86. end
  87.  
  88. -- Get user input
  89. local function getInput(prompt)
  90. if prompt then
  91. os.display.setForeground(GREEN)
  92. io.write(prompt)
  93. os.display.setForeground(WHITE)
  94. end
  95. return io.read()
  96. end
  97.  
  98. -- Get number input
  99. local function getNumber(prompt, default)
  100. local input = getInput(prompt)
  101. if input == "" and default then
  102. return default
  103. end
  104. return tonumber(input) or default or 0
  105. end
  106.  
  107. -- Add Text Widget
  108. local function addTextWidget()
  109. drawHeader("Add Text Widget")
  110.  
  111. local text = getInput("Enter text to display: ")
  112. if not text or text == "" then
  113. print("Cancelled.")
  114. os.system.sleep(1)
  115. return
  116. end
  117.  
  118. local x = getNumber("X position (default 0): ", 0)
  119. local y = getNumber("Y position (default 0): ", 0)
  120.  
  121. print("\nColor options:")
  122. print("1. White 2. Red 3. Green 4. Blue 5. Yellow 6. Cyan")
  123. local colorChoice = getNumber("Select color (1-6, default 1): ", 1)
  124.  
  125. local colors = {WHITE, RED, GREEN, BLUE, YELLOW, CYAN}
  126. local color = colors[colorChoice] or WHITE
  127.  
  128. local alpha = getNumber("Alpha/Opacity (0-255, default 255): ", 255)
  129.  
  130. -- Create widget
  131. local widget = glasses.addTextLabel()
  132. widget.setText(text)
  133. widget.setPosition(x, y)
  134. widget.setColor(color)
  135. widget.setAlpha(alpha / 255)
  136.  
  137. table.insert(widgetList, {type = "text", obj = widget, desc = text})
  138.  
  139. os.display.setForeground(GREEN)
  140. print("\n✓ Text widget created successfully!")
  141. os.display.setForeground(WHITE)
  142. os.system.sleep(2)
  143. end
  144.  
  145. -- Add Item Icon Widget
  146. local function addItemWidget()
  147. drawHeader("Add Item Icon Widget")
  148.  
  149. local itemName = getInput("Enter item name (e.g., minecraft:diamond): ")
  150. if not itemName or itemName == "" then
  151. print("Cancelled.")
  152. os.system.sleep(1)
  153. return
  154. end
  155.  
  156. local x = getNumber("X position (default 0): ", 0)
  157. local y = getNumber("Y position (default 0): ", 0)
  158. local scale = getNumber("Scale (default 1.0): ", 1.0)
  159.  
  160. -- Create widget
  161. local widget = glasses.addIcon()
  162. widget.setItemName(itemName)
  163. widget.setPosition(x, y)
  164. widget.setScale(scale)
  165.  
  166. table.insert(widgetList, {type = "icon", obj = widget, desc = itemName})
  167.  
  168. os.display.setForeground(GREEN)
  169. print("\n✓ Item icon widget created successfully!")
  170. os.display.setForeground(WHITE)
  171. os.system.sleep(2)
  172. end
  173.  
  174. -- Add Fluid/Energy Bar Widget
  175. local function addBarWidget()
  176. drawHeader("Add Bar Widget")
  177.  
  178. print("Bar Type:")
  179. print("1. Fluid Bar")
  180. print("2. Energy Bar")
  181. local barType = getNumber("Select type (1-2): ", 1)
  182.  
  183. local x = getNumber("X position (default 0): ", 0)
  184. local y = getNumber("Y position (default 0): ", 0)
  185. local width = getNumber("Width (default 50): ", 50)
  186. local height = getNumber("Height (default 10): ", 10)
  187. local value = getNumber("Current value (0-100, default 50): ", 50)
  188.  
  189. -- Create widget based on type
  190. local widget
  191. if barType == 2 then
  192. widget = glasses.addEnergyBar()
  193. else
  194. widget = glasses.addFluidBar()
  195. local fluidName = getInput("Fluid name (e.g., water): ")
  196. if fluidName and fluidName ~= "" then
  197. widget.setFluid(fluidName)
  198. end
  199. end
  200.  
  201. widget.setPosition(x, y)
  202. widget.setSize(width, height)
  203. widget.setLevel(value / 100)
  204.  
  205. local desc = (barType == 2 and "Energy Bar" or "Fluid Bar")
  206. table.insert(widgetList, {type = "bar", obj = widget, desc = desc})
  207.  
  208. os.display.setForeground(GREEN)
  209. print("\n✓ Bar widget created successfully!")
  210. os.display.setForeground(WHITE)
  211. os.system.sleep(2)
  212. end
  213.  
  214. -- Add Dotted Line
  215. local function addDottedLine()
  216. drawHeader("Add Dotted Line")
  217.  
  218. local x1 = getNumber("Start X (default 0): ", 0)
  219. local y1 = getNumber("Start Y (default 0): ", 0)
  220. local x2 = getNumber("End X (default 100): ", 100)
  221. local y2 = getNumber("End Y (default 100): ", 100)
  222.  
  223. local widget = glasses.addDotMatrix()
  224. widget.setPosition(x1, y1)
  225. widget.setSize(x2 - x1, y2 - y1)
  226.  
  227. table.insert(widgetList, {type = "dots", obj = widget, desc = "Dotted Line"})
  228.  
  229. os.display.setForeground(GREEN)
  230. print("\n✓ Dotted line created successfully!")
  231. os.display.setForeground(WHITE)
  232. os.system.sleep(2)
  233. end
  234.  
  235. -- Add Rectangle
  236. local function addRectangle()
  237. drawHeader("Add Rectangle/Frame")
  238.  
  239. local x = getNumber("X position (default 0): ", 0)
  240. local y = getNumber("Y position (default 0): ", 0)
  241. local width = getNumber("Width (default 100): ", 100)
  242. local height = getNumber("Height (default 50): ", 50)
  243.  
  244. print("\nFill or outline?")
  245. print("1. Filled 2. Outline only")
  246. local fillType = getNumber("Select (1-2, default 2): ", 2)
  247.  
  248. local widget = glasses.addRect()
  249. widget.setPosition(x, y)
  250. widget.setSize(width, height)
  251.  
  252. if fillType == 1 then
  253. widget.setColor(0x0000FF)
  254. widget.setAlpha(0.5)
  255. else
  256. widget.setColor(WHITE)
  257. widget.setAlpha(0.8)
  258. end
  259.  
  260. table.insert(widgetList, {type = "rect", obj = widget, desc = "Rectangle"})
  261.  
  262. os.display.setForeground(GREEN)
  263. print("\n✓ Rectangle created successfully!")
  264. os.display.setForeground(WHITE)
  265. os.system.sleep(2)
  266. end
  267.  
  268. -- Add 3D Cube
  269. local function addCube()
  270. drawHeader("Add 3D Cube")
  271.  
  272. local x = getNumber("X position (default 0): ", 0)
  273. local y = getNumber("Y position (default 64): ", 64)
  274. local z = getNumber("Z position (default 0): ", 0)
  275. local size = getNumber("Size (default 1): ", 1)
  276.  
  277. local cube = glasses.addCube3D()
  278. cube.set3DPos(x, y, z)
  279. cube.setSize(size)
  280. cube.setColor(0x00FF00)
  281. cube.setAlpha(0.7)
  282.  
  283. table.insert(objectList, {type = "cube", obj = cube, desc = "Cube at " .. x .. "," .. y .. "," .. z})
  284.  
  285. os.display.setForeground(GREEN)
  286. print("\n✓ 3D Cube created successfully!")
  287. os.display.setForeground(WHITE)
  288. os.system.sleep(2)
  289. end
  290.  
  291. -- Add 3D Quad
  292. local function addQuad()
  293. drawHeader("Add 3D Quad (Flat Rectangle)")
  294.  
  295. local x = getNumber("X position (default 0): ", 0)
  296. local y = getNumber("Y position (default 64): ", 64)
  297. local z = getNumber("Z position (default 0): ", 0)
  298. local width = getNumber("Width (default 2): ", 2)
  299. local height = getNumber("Height (default 2): ", 2)
  300.  
  301. local quad = glasses.addQuad3D()
  302. quad.set3DPos(x, y, z)
  303. quad.setSize(width, height)
  304. quad.setColor(0xFF00FF)
  305. quad.setAlpha(0.8)
  306.  
  307. table.insert(objectList, {type = "quad", obj = quad, desc = "Quad at " .. x .. "," .. y .. "," .. z})
  308.  
  309. os.display.setForeground(GREEN)
  310. print("\n✓ 3D Quad created successfully!")
  311. os.display.setForeground(WHITE)
  312. os.system.sleep(2)
  313. end
  314.  
  315. -- Add 3D Line
  316. local function add3DLine()
  317. drawHeader("Add 3D Line")
  318.  
  319. local x1 = getNumber("Start X (default 0): ", 0)
  320. local y1 = getNumber("Start Y (default 64): ", 64)
  321. local z1 = getNumber("Start Z (default 0): ", 0)
  322. local x2 = getNumber("End X (default 5): ", 5)
  323. local y2 = getNumber("End Y (default 64): ", 64)
  324. local z2 = getNumber("End Z (default 5): ", 5)
  325.  
  326. local line = glasses.addLine3D()
  327. line.set3DPos(x1, y1, z1, x2, y2, z2)
  328. line.setColor(0xFFFF00)
  329.  
  330. table.insert(objectList, {type = "line", obj = line, desc = "Line 3D"})
  331.  
  332. os.display.setForeground(GREEN)
  333. print("\n✓ 3D Line created successfully!")
  334. os.display.setForeground(WHITE)
  335. os.system.sleep(2)
  336. end
  337.  
  338. -- List Widgets
  339. local function listWidgets()
  340. drawHeader("Widget List")
  341.  
  342. if #widgetList == 0 then
  343. print("No widgets currently active.")
  344. else
  345. for i, widget in ipairs(widgetList) do
  346. print(i .. ". [" .. widget.type .. "] " .. widget.desc)
  347. end
  348. end
  349.  
  350. print("\nPress Enter to continue...")
  351. io.read()
  352. end
  353.  
  354. -- List 3D Objects
  355. local function list3DObjects()
  356. drawHeader("3D Object List")
  357.  
  358. if #objectList == 0 then
  359. print("No 3D objects currently active.")
  360. else
  361. for i, obj in ipairs(objectList) do
  362. print(i .. ". [" .. obj.type .. "] " .. obj.desc)
  363. end
  364. end
  365.  
  366. print("\nPress Enter to continue...")
  367. io.read()
  368. end
  369.  
  370. -- Remove Widget
  371. local function removeWidget()
  372. listWidgets()
  373.  
  374. if #widgetList == 0 then
  375. os.system.sleep(1)
  376. return
  377. end
  378.  
  379. local index = getNumber("\nEnter widget number to remove (0 to cancel): ", 0)
  380.  
  381. if index > 0 and index <= #widgetList then
  382. widgetList[index].obj.removeAll()
  383. table.remove(widgetList, index)
  384. os.display.setForeground(GREEN)
  385. print("\n✓ Widget removed!")
  386. os.display.setForeground(WHITE)
  387. end
  388.  
  389. os.system.sleep(1)
  390. end
  391.  
  392. -- Remove 3D Object
  393. local function remove3DObject()
  394. list3DObjects()
  395.  
  396. if #objectList == 0 then
  397. os.system.sleep(1)
  398. return
  399. end
  400.  
  401. local index = getNumber("\nEnter object number to remove (0 to cancel): ", 0)
  402.  
  403. if index > 0 and index <= #objectList then
  404. objectList[index].obj.removeAll()
  405. table.remove(objectList, index)
  406. os.display.setForeground(GREEN)
  407. print("\n✓ Object removed!")
  408. os.display.setForeground(WHITE)
  409. end
  410.  
  411. os.system.sleep(1)
  412. end
  413.  
  414. -- Radar Controls
  415. local function radarControls()
  416. drawHeader("Radar Controls")
  417.  
  418. print("1. Enable Player Radar")
  419. print("2. Disable Player Radar")
  420. print("3. Set Radar Range")
  421. print("4. Show Nearby Players")
  422. print("5. Back")
  423.  
  424. local choice = getInput("\nSelect option: ")
  425.  
  426. if choice == "1" then
  427. glasses.setPlayerRadarEnabled(true)
  428. print("\n✓ Player radar enabled!")
  429. os.system.sleep(1)
  430. elseif choice == "2" then
  431. glasses.setPlayerRadarEnabled(false)
  432. print("\n✓ Player radar disabled!")
  433. os.system.sleep(1)
  434. elseif choice == "3" then
  435. local range = getNumber("Enter radar range in blocks (default 50): ", 50)
  436. glasses.setPlayerRadarRange(range)
  437. print("\n✓ Radar range set to " .. range .. " blocks!")
  438. os.system.sleep(1)
  439. elseif choice == "4" then
  440. -- This would require radar upgrade on tablet
  441. print("\nScanning for players...")
  442. print("(Requires radar upgrade on tablet)")
  443. os.system.sleep(2)
  444. end
  445. end
  446.  
  447. -- Navigation System
  448. local function navigationSystem()
  449. drawHeader("Navigation System")
  450.  
  451. print("1. Set Waypoint Marker")
  452. print("2. Create Navigation Path")
  453. print("3. Add Floating Label")
  454. print("4. Back")
  455.  
  456. local choice = getInput("\nSelect option: ")
  457.  
  458. if choice == "1" then
  459. local x = getNumber("Waypoint X: ", 0)
  460. local y = getNumber("Waypoint Y: ", 64)
  461. local z = getNumber("Waypoint Z: ", 0)
  462. local name = getInput("Waypoint name: ") or "Waypoint"
  463.  
  464. -- Create waypoint marker
  465. local marker = glasses.addCube3D()
  466. marker.set3DPos(x, y, z)
  467. marker.setSize(0.5)
  468. marker.setColor(0xFF0000)
  469. marker.setAlpha(0.8)
  470.  
  471. local label = glasses.addFloatingText()
  472. label.set3DPos(x, y + 1, z)
  473. label.setText(name)
  474. label.setScale(0.5)
  475.  
  476. table.insert(objectList, {type = "waypoint", obj = marker, desc = name})
  477. table.insert(objectList, {type = "label", obj = label, desc = name .. " label"})
  478.  
  479. os.display.setForeground(GREEN)
  480. print("\n✓ Waypoint created!")
  481. os.display.setForeground(WHITE)
  482. os.system.sleep(2)
  483.  
  484. elseif choice == "3" then
  485. local x = getNumber("Label X: ", 0)
  486. local y = getNumber("Label Y: ", 64)
  487. local z = getNumber("Label Z: ", 0)
  488. local text = getInput("Label text: ") or "Label"
  489.  
  490. local label = glasses.addFloatingText()
  491. label.set3DPos(x, y, z)
  492. label.setText(text)
  493. label.setColor(0x00FFFF)
  494. label.setScale(0.5)
  495.  
  496. table.insert(objectList, {type = "label", obj = label, desc = text})
  497.  
  498. os.display.setForeground(GREEN)
  499. print("\n✓ Label created!")
  500. os.display.setForeground(WHITE)
  501. os.system.sleep(2)
  502. end
  503. end
  504.  
  505. -- Quick Actions
  506. local function quickActions()
  507. drawHeader("Quick Actions")
  508.  
  509. print("1. Create HUD Overlay")
  510. print("2. Create Compass")
  511. print("3. Create Health/Energy Display")
  512. print("4. Create Coordinate Display")
  513. print("5. Back")
  514.  
  515. local choice = getInput("\nSelect option: ")
  516.  
  517. if choice == "1" then
  518. -- Simple HUD
  519. local frame = glasses.addRect()
  520. frame.setPosition(5, 5)
  521. frame.setSize(200, 100)
  522. frame.setColor(0x000000)
  523. frame.setAlpha(0.5)
  524.  
  525. local title = glasses.addTextLabel()
  526. title.setPosition(10, 10)
  527. title.setText("HUD Active")
  528. title.setColor(0x00FF00)
  529.  
  530. table.insert(widgetList, {type = "hud", obj = frame, desc = "HUD Frame"})
  531. table.insert(widgetList, {type = "hud", obj = title, desc = "HUD Title"})
  532.  
  533. print("\n✓ HUD overlay created!")
  534. os.system.sleep(2)
  535.  
  536. elseif choice == "4" then
  537. local coordLabel = glasses.addTextLabel()
  538. coordLabel.setPosition(5, 5)
  539. coordLabel.setText("X: 0 Y: 64 Z: 0")
  540. coordLabel.setColor(0xFFFF00)
  541.  
  542. table.insert(widgetList, {type = "coords", obj = coordLabel, desc = "Coordinates"})
  543.  
  544. print("\n✓ Coordinate display created!")
  545. print("Note: Coordinates are static. Use navigation upgrade for live updates.")
  546. os.system.sleep(2)
  547. end
  548. end
  549.  
  550. -- Clear All Objects
  551. local function clearAll()
  552. drawHeader("Clear All Objects")
  553.  
  554. print("This will remove ALL widgets and 3D objects.")
  555. local confirm = getInput("Type 'YES' to confirm: ")
  556.  
  557. if confirm == "YES" then
  558. glasses.removeAll()
  559. widgetList = {}
  560. objectList = {}
  561.  
  562. os.display.setForeground(GREEN)
  563. print("\n✓ All objects cleared!")
  564. os.display.setForeground(WHITE)
  565. else
  566. print("\nCancelled.")
  567. end
  568.  
  569. os.system.sleep(2)
  570. end
  571.  
  572. -- Settings and Info
  573. local function settingsInfo()
  574. drawHeader("Settings & Information")
  575.  
  576. print("Glasses Component Status:")
  577. if glasses then
  578. print(" Status: Connected")
  579.  
  580. -- Try to get some glasses info
  581. local success, bind = pcall(function() return glasses.getBind() end)
  582. if success and bind then
  583. print(" Bound to: " .. bind)
  584. end
  585. else
  586. os.display.setForeground(RED)
  587. print(" Status: NOT CONNECTED")
  588. os.display.setForeground(WHITE)
  589. end
  590.  
  591. print("\nActive Objects:")
  592. print(" Widgets: " .. #widgetList)
  593. print(" 3D Objects: " .. #objectList)
  594.  
  595. print("\nFeatures Available:")
  596. print(" ✓ 2D Widgets (Text, Icons, Bars, Shapes)")
  597. print(" ✓ 3D Objects (Cubes, Quads, Lines)")
  598. print(" ✓ Floating Labels")
  599. print(" ✓ Player Radar")
  600. print(" ✓ Navigation Markers")
  601.  
  602. print("\nPress Enter to continue...")
  603. io.read()
  604. end
  605.  
  606. -- Widget Manager Loop
  607. local function widgetManager()
  608. while true do
  609. showWidgetMenu()
  610. local choice = getInput()
  611.  
  612. if choice == "1" then
  613. addTextWidget()
  614. elseif choice == "2" then
  615. addItemWidget()
  616. elseif choice == "3" then
  617. addBarWidget()
  618. elseif choice == "4" then
  619. addDottedLine()
  620. elseif choice == "5" then
  621. addRectangle()
  622. elseif choice == "6" then
  623. listWidgets()
  624. elseif choice == "7" then
  625. removeWidget()
  626. elseif choice == "8" then
  627. return
  628. end
  629. end
  630. end
  631.  
  632. -- 3D Object Manager Loop
  633. local function object3DManager()
  634. while true do
  635. show3DMenu()
  636. local choice = getInput()
  637.  
  638. if choice == "1" then
  639. addCube()
  640. elseif choice == "2" then
  641. addQuad()
  642. elseif choice == "3" then
  643. print("\nTriangle creation - coming soon!")
  644. os.system.sleep(1)
  645. elseif choice == "4" then
  646. add3DLine()
  647. elseif choice == "5" then
  648. print("\nPoint cloud creation - coming soon!")
  649. os.system.sleep(1)
  650. elseif choice == "6" then
  651. list3DObjects()
  652. elseif choice == "7" then
  653. remove3DObject()
  654. elseif choice == "8" then
  655. return
  656. end
  657. end
  658. end
  659.  
  660. -- Main Program Loop
  661. local function main()
  662. -- Initialize
  663. if not initGlasses() then
  664. os.display.setForeground(RED)
  665. print("ERROR: No OpenGlasses 2 component found!")
  666. print("Please ensure glasses are installed and linked.")
  667. os.display.setForeground(WHITE)
  668. return
  669. end
  670.  
  671. -- Main loop
  672. while running do
  673. showMainMenu()
  674. local choice = getInput()
  675.  
  676. if choice == "1" then
  677. widgetManager()
  678. elseif choice == "2" then
  679. object3DManager()
  680. elseif choice == "3" then
  681. print("\nSurface manager - coming soon!")
  682. os.system.sleep(2)
  683. elseif choice == "4" then
  684. radarControls()
  685. elseif choice == "5" then
  686. navigationSystem()
  687. elseif choice == "6" then
  688. quickActions()
  689. elseif choice == "7" then
  690. settingsInfo()
  691. elseif choice == "8" then
  692. clearAll()
  693. elseif choice == "9" then
  694. running = false
  695. end
  696. end
  697.  
  698. os.display.setForeground(CYAN)
  699. print("\nThank you for using OpenGlasses 2 AR Control Suite!")
  700. os.display.setForeground(WHITE)
  701. end
  702.  
  703. -- Run the program
  704. main()
  705.  
Advertisement
Add Comment
Please, Sign In to add comment