Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --HELP: OpenGlasses 2 AR Control Suite - Full control of AR glasses features. Usage: GLASSES
- -- OpenGlasses 2 AR Control Suite for M-DOS
- -- Supports all OpenGlasses 2 features including widgets, 3D objects, radar, and navigation
- local running = true
- local glasses = nil
- local currentMenu = "main"
- local widgetList = {}
- local objectList = {}
- local radarPlayers = {}
- -- Colors
- local WHITE = 0xFFFFFF
- local CYAN = 0x00FFFF
- local GREEN = 0x00FF00
- local YELLOW = 0xFFFF00
- local RED = 0xFF0000
- local BLUE = 0x0000FF
- local GRAY = 0x808080
- -- Initialize glasses component
- local function initGlasses()
- local component = require("component")
- if component.isAvailable("glasses") then
- glasses = component.glasses
- return true
- end
- return false
- end
- -- Clear screen and draw header
- local function drawHeader(title)
- os.display.clear()
- os.display.setForeground(CYAN)
- print("╔════════════════════════════════════════════════════════════════════╗")
- print("║ OpenGlasses 2 AR Control Suite v1.0 ║")
- print("╚════════════════════════════════════════════════════════════════════╝")
- os.display.setForeground(YELLOW)
- print("\n" .. title)
- os.display.setForeground(WHITE)
- print(string.rep("─", 70) .. "\n")
- end
- -- Main Menu
- local function showMainMenu()
- drawHeader("Main Menu")
- print("1. Widget Manager")
- print("2. 3D Object Manager")
- print("3. Surface Manager")
- print("4. Radar Controls")
- print("5. Navigation System")
- print("6. Quick Actions")
- print("7. Settings & Info")
- print("8. Clear All Objects")
- print("9. Exit")
- print("\nSelect option (1-9): ")
- end
- -- Widget Manager Menu
- local function showWidgetMenu()
- drawHeader("Widget Manager")
- print("1. Add Text Widget")
- print("2. Add Item Icon Widget")
- print("3. Add Fluid/Energy Bar Widget")
- print("4. Add Dotted Line")
- print("5. Add Rectangle/Frame")
- print("6. List All Widgets")
- print("7. Remove Widget")
- print("8. Back to Main Menu")
- print("\nSelect option (1-8): ")
- end
- -- 3D Object Manager Menu
- local function show3DMenu()
- drawHeader("3D Object Manager")
- print("1. Add Cube")
- print("2. Add Quad (Flat Rectangle)")
- print("3. Add Triangle")
- print("4. Add Line (3D)")
- print("5. Add Point Cloud")
- print("6. List All 3D Objects")
- print("7. Remove 3D Object")
- print("8. Back to Main Menu")
- print("\nSelect option (1-8): ")
- end
- -- Get user input
- local function getInput(prompt)
- if prompt then
- os.display.setForeground(GREEN)
- io.write(prompt)
- os.display.setForeground(WHITE)
- end
- return io.read()
- end
- -- Get number input
- local function getNumber(prompt, default)
- local input = getInput(prompt)
- if input == "" and default then
- return default
- end
- return tonumber(input) or default or 0
- end
- -- Add Text Widget
- local function addTextWidget()
- drawHeader("Add Text Widget")
- local text = getInput("Enter text to display: ")
- if not text or text == "" then
- print("Cancelled.")
- os.system.sleep(1)
- return
- end
- local x = getNumber("X position (default 0): ", 0)
- local y = getNumber("Y position (default 0): ", 0)
- print("\nColor options:")
- print("1. White 2. Red 3. Green 4. Blue 5. Yellow 6. Cyan")
- local colorChoice = getNumber("Select color (1-6, default 1): ", 1)
- local colors = {WHITE, RED, GREEN, BLUE, YELLOW, CYAN}
- local color = colors[colorChoice] or WHITE
- local alpha = getNumber("Alpha/Opacity (0-255, default 255): ", 255)
- -- Create widget
- local widget = glasses.addTextLabel()
- widget.setText(text)
- widget.setPosition(x, y)
- widget.setColor(color)
- widget.setAlpha(alpha / 255)
- table.insert(widgetList, {type = "text", obj = widget, desc = text})
- os.display.setForeground(GREEN)
- print("\n✓ Text widget created successfully!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- -- Add Item Icon Widget
- local function addItemWidget()
- drawHeader("Add Item Icon Widget")
- local itemName = getInput("Enter item name (e.g., minecraft:diamond): ")
- if not itemName or itemName == "" then
- print("Cancelled.")
- os.system.sleep(1)
- return
- end
- local x = getNumber("X position (default 0): ", 0)
- local y = getNumber("Y position (default 0): ", 0)
- local scale = getNumber("Scale (default 1.0): ", 1.0)
- -- Create widget
- local widget = glasses.addIcon()
- widget.setItemName(itemName)
- widget.setPosition(x, y)
- widget.setScale(scale)
- table.insert(widgetList, {type = "icon", obj = widget, desc = itemName})
- os.display.setForeground(GREEN)
- print("\n✓ Item icon widget created successfully!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- -- Add Fluid/Energy Bar Widget
- local function addBarWidget()
- drawHeader("Add Bar Widget")
- print("Bar Type:")
- print("1. Fluid Bar")
- print("2. Energy Bar")
- local barType = getNumber("Select type (1-2): ", 1)
- local x = getNumber("X position (default 0): ", 0)
- local y = getNumber("Y position (default 0): ", 0)
- local width = getNumber("Width (default 50): ", 50)
- local height = getNumber("Height (default 10): ", 10)
- local value = getNumber("Current value (0-100, default 50): ", 50)
- -- Create widget based on type
- local widget
- if barType == 2 then
- widget = glasses.addEnergyBar()
- else
- widget = glasses.addFluidBar()
- local fluidName = getInput("Fluid name (e.g., water): ")
- if fluidName and fluidName ~= "" then
- widget.setFluid(fluidName)
- end
- end
- widget.setPosition(x, y)
- widget.setSize(width, height)
- widget.setLevel(value / 100)
- local desc = (barType == 2 and "Energy Bar" or "Fluid Bar")
- table.insert(widgetList, {type = "bar", obj = widget, desc = desc})
- os.display.setForeground(GREEN)
- print("\n✓ Bar widget created successfully!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- -- Add Dotted Line
- local function addDottedLine()
- drawHeader("Add Dotted Line")
- local x1 = getNumber("Start X (default 0): ", 0)
- local y1 = getNumber("Start Y (default 0): ", 0)
- local x2 = getNumber("End X (default 100): ", 100)
- local y2 = getNumber("End Y (default 100): ", 100)
- local widget = glasses.addDotMatrix()
- widget.setPosition(x1, y1)
- widget.setSize(x2 - x1, y2 - y1)
- table.insert(widgetList, {type = "dots", obj = widget, desc = "Dotted Line"})
- os.display.setForeground(GREEN)
- print("\n✓ Dotted line created successfully!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- -- Add Rectangle
- local function addRectangle()
- drawHeader("Add Rectangle/Frame")
- local x = getNumber("X position (default 0): ", 0)
- local y = getNumber("Y position (default 0): ", 0)
- local width = getNumber("Width (default 100): ", 100)
- local height = getNumber("Height (default 50): ", 50)
- print("\nFill or outline?")
- print("1. Filled 2. Outline only")
- local fillType = getNumber("Select (1-2, default 2): ", 2)
- local widget = glasses.addRect()
- widget.setPosition(x, y)
- widget.setSize(width, height)
- if fillType == 1 then
- widget.setColor(0x0000FF)
- widget.setAlpha(0.5)
- else
- widget.setColor(WHITE)
- widget.setAlpha(0.8)
- end
- table.insert(widgetList, {type = "rect", obj = widget, desc = "Rectangle"})
- os.display.setForeground(GREEN)
- print("\n✓ Rectangle created successfully!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- -- Add 3D Cube
- local function addCube()
- drawHeader("Add 3D Cube")
- local x = getNumber("X position (default 0): ", 0)
- local y = getNumber("Y position (default 64): ", 64)
- local z = getNumber("Z position (default 0): ", 0)
- local size = getNumber("Size (default 1): ", 1)
- local cube = glasses.addCube3D()
- cube.set3DPos(x, y, z)
- cube.setSize(size)
- cube.setColor(0x00FF00)
- cube.setAlpha(0.7)
- table.insert(objectList, {type = "cube", obj = cube, desc = "Cube at " .. x .. "," .. y .. "," .. z})
- os.display.setForeground(GREEN)
- print("\n✓ 3D Cube created successfully!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- -- Add 3D Quad
- local function addQuad()
- drawHeader("Add 3D Quad (Flat Rectangle)")
- local x = getNumber("X position (default 0): ", 0)
- local y = getNumber("Y position (default 64): ", 64)
- local z = getNumber("Z position (default 0): ", 0)
- local width = getNumber("Width (default 2): ", 2)
- local height = getNumber("Height (default 2): ", 2)
- local quad = glasses.addQuad3D()
- quad.set3DPos(x, y, z)
- quad.setSize(width, height)
- quad.setColor(0xFF00FF)
- quad.setAlpha(0.8)
- table.insert(objectList, {type = "quad", obj = quad, desc = "Quad at " .. x .. "," .. y .. "," .. z})
- os.display.setForeground(GREEN)
- print("\n✓ 3D Quad created successfully!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- -- Add 3D Line
- local function add3DLine()
- drawHeader("Add 3D Line")
- local x1 = getNumber("Start X (default 0): ", 0)
- local y1 = getNumber("Start Y (default 64): ", 64)
- local z1 = getNumber("Start Z (default 0): ", 0)
- local x2 = getNumber("End X (default 5): ", 5)
- local y2 = getNumber("End Y (default 64): ", 64)
- local z2 = getNumber("End Z (default 5): ", 5)
- local line = glasses.addLine3D()
- line.set3DPos(x1, y1, z1, x2, y2, z2)
- line.setColor(0xFFFF00)
- table.insert(objectList, {type = "line", obj = line, desc = "Line 3D"})
- os.display.setForeground(GREEN)
- print("\n✓ 3D Line created successfully!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- -- List Widgets
- local function listWidgets()
- drawHeader("Widget List")
- if #widgetList == 0 then
- print("No widgets currently active.")
- else
- for i, widget in ipairs(widgetList) do
- print(i .. ". [" .. widget.type .. "] " .. widget.desc)
- end
- end
- print("\nPress Enter to continue...")
- io.read()
- end
- -- List 3D Objects
- local function list3DObjects()
- drawHeader("3D Object List")
- if #objectList == 0 then
- print("No 3D objects currently active.")
- else
- for i, obj in ipairs(objectList) do
- print(i .. ". [" .. obj.type .. "] " .. obj.desc)
- end
- end
- print("\nPress Enter to continue...")
- io.read()
- end
- -- Remove Widget
- local function removeWidget()
- listWidgets()
- if #widgetList == 0 then
- os.system.sleep(1)
- return
- end
- local index = getNumber("\nEnter widget number to remove (0 to cancel): ", 0)
- if index > 0 and index <= #widgetList then
- widgetList[index].obj.removeAll()
- table.remove(widgetList, index)
- os.display.setForeground(GREEN)
- print("\n✓ Widget removed!")
- os.display.setForeground(WHITE)
- end
- os.system.sleep(1)
- end
- -- Remove 3D Object
- local function remove3DObject()
- list3DObjects()
- if #objectList == 0 then
- os.system.sleep(1)
- return
- end
- local index = getNumber("\nEnter object number to remove (0 to cancel): ", 0)
- if index > 0 and index <= #objectList then
- objectList[index].obj.removeAll()
- table.remove(objectList, index)
- os.display.setForeground(GREEN)
- print("\n✓ Object removed!")
- os.display.setForeground(WHITE)
- end
- os.system.sleep(1)
- end
- -- Radar Controls
- local function radarControls()
- drawHeader("Radar Controls")
- print("1. Enable Player Radar")
- print("2. Disable Player Radar")
- print("3. Set Radar Range")
- print("4. Show Nearby Players")
- print("5. Back")
- local choice = getInput("\nSelect option: ")
- if choice == "1" then
- glasses.setPlayerRadarEnabled(true)
- print("\n✓ Player radar enabled!")
- os.system.sleep(1)
- elseif choice == "2" then
- glasses.setPlayerRadarEnabled(false)
- print("\n✓ Player radar disabled!")
- os.system.sleep(1)
- elseif choice == "3" then
- local range = getNumber("Enter radar range in blocks (default 50): ", 50)
- glasses.setPlayerRadarRange(range)
- print("\n✓ Radar range set to " .. range .. " blocks!")
- os.system.sleep(1)
- elseif choice == "4" then
- -- This would require radar upgrade on tablet
- print("\nScanning for players...")
- print("(Requires radar upgrade on tablet)")
- os.system.sleep(2)
- end
- end
- -- Navigation System
- local function navigationSystem()
- drawHeader("Navigation System")
- print("1. Set Waypoint Marker")
- print("2. Create Navigation Path")
- print("3. Add Floating Label")
- print("4. Back")
- local choice = getInput("\nSelect option: ")
- if choice == "1" then
- local x = getNumber("Waypoint X: ", 0)
- local y = getNumber("Waypoint Y: ", 64)
- local z = getNumber("Waypoint Z: ", 0)
- local name = getInput("Waypoint name: ") or "Waypoint"
- -- Create waypoint marker
- local marker = glasses.addCube3D()
- marker.set3DPos(x, y, z)
- marker.setSize(0.5)
- marker.setColor(0xFF0000)
- marker.setAlpha(0.8)
- local label = glasses.addFloatingText()
- label.set3DPos(x, y + 1, z)
- label.setText(name)
- label.setScale(0.5)
- table.insert(objectList, {type = "waypoint", obj = marker, desc = name})
- table.insert(objectList, {type = "label", obj = label, desc = name .. " label"})
- os.display.setForeground(GREEN)
- print("\n✓ Waypoint created!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- elseif choice == "3" then
- local x = getNumber("Label X: ", 0)
- local y = getNumber("Label Y: ", 64)
- local z = getNumber("Label Z: ", 0)
- local text = getInput("Label text: ") or "Label"
- local label = glasses.addFloatingText()
- label.set3DPos(x, y, z)
- label.setText(text)
- label.setColor(0x00FFFF)
- label.setScale(0.5)
- table.insert(objectList, {type = "label", obj = label, desc = text})
- os.display.setForeground(GREEN)
- print("\n✓ Label created!")
- os.display.setForeground(WHITE)
- os.system.sleep(2)
- end
- end
- -- Quick Actions
- local function quickActions()
- drawHeader("Quick Actions")
- print("1. Create HUD Overlay")
- print("2. Create Compass")
- print("3. Create Health/Energy Display")
- print("4. Create Coordinate Display")
- print("5. Back")
- local choice = getInput("\nSelect option: ")
- if choice == "1" then
- -- Simple HUD
- local frame = glasses.addRect()
- frame.setPosition(5, 5)
- frame.setSize(200, 100)
- frame.setColor(0x000000)
- frame.setAlpha(0.5)
- local title = glasses.addTextLabel()
- title.setPosition(10, 10)
- title.setText("HUD Active")
- title.setColor(0x00FF00)
- table.insert(widgetList, {type = "hud", obj = frame, desc = "HUD Frame"})
- table.insert(widgetList, {type = "hud", obj = title, desc = "HUD Title"})
- print("\n✓ HUD overlay created!")
- os.system.sleep(2)
- elseif choice == "4" then
- local coordLabel = glasses.addTextLabel()
- coordLabel.setPosition(5, 5)
- coordLabel.setText("X: 0 Y: 64 Z: 0")
- coordLabel.setColor(0xFFFF00)
- table.insert(widgetList, {type = "coords", obj = coordLabel, desc = "Coordinates"})
- print("\n✓ Coordinate display created!")
- print("Note: Coordinates are static. Use navigation upgrade for live updates.")
- os.system.sleep(2)
- end
- end
- -- Clear All Objects
- local function clearAll()
- drawHeader("Clear All Objects")
- print("This will remove ALL widgets and 3D objects.")
- local confirm = getInput("Type 'YES' to confirm: ")
- if confirm == "YES" then
- glasses.removeAll()
- widgetList = {}
- objectList = {}
- os.display.setForeground(GREEN)
- print("\n✓ All objects cleared!")
- os.display.setForeground(WHITE)
- else
- print("\nCancelled.")
- end
- os.system.sleep(2)
- end
- -- Settings and Info
- local function settingsInfo()
- drawHeader("Settings & Information")
- print("Glasses Component Status:")
- if glasses then
- print(" Status: Connected")
- -- Try to get some glasses info
- local success, bind = pcall(function() return glasses.getBind() end)
- if success and bind then
- print(" Bound to: " .. bind)
- end
- else
- os.display.setForeground(RED)
- print(" Status: NOT CONNECTED")
- os.display.setForeground(WHITE)
- end
- print("\nActive Objects:")
- print(" Widgets: " .. #widgetList)
- print(" 3D Objects: " .. #objectList)
- print("\nFeatures Available:")
- print(" ✓ 2D Widgets (Text, Icons, Bars, Shapes)")
- print(" ✓ 3D Objects (Cubes, Quads, Lines)")
- print(" ✓ Floating Labels")
- print(" ✓ Player Radar")
- print(" ✓ Navigation Markers")
- print("\nPress Enter to continue...")
- io.read()
- end
- -- Widget Manager Loop
- local function widgetManager()
- while true do
- showWidgetMenu()
- local choice = getInput()
- if choice == "1" then
- addTextWidget()
- elseif choice == "2" then
- addItemWidget()
- elseif choice == "3" then
- addBarWidget()
- elseif choice == "4" then
- addDottedLine()
- elseif choice == "5" then
- addRectangle()
- elseif choice == "6" then
- listWidgets()
- elseif choice == "7" then
- removeWidget()
- elseif choice == "8" then
- return
- end
- end
- end
- -- 3D Object Manager Loop
- local function object3DManager()
- while true do
- show3DMenu()
- local choice = getInput()
- if choice == "1" then
- addCube()
- elseif choice == "2" then
- addQuad()
- elseif choice == "3" then
- print("\nTriangle creation - coming soon!")
- os.system.sleep(1)
- elseif choice == "4" then
- add3DLine()
- elseif choice == "5" then
- print("\nPoint cloud creation - coming soon!")
- os.system.sleep(1)
- elseif choice == "6" then
- list3DObjects()
- elseif choice == "7" then
- remove3DObject()
- elseif choice == "8" then
- return
- end
- end
- end
- -- Main Program Loop
- local function main()
- -- Initialize
- if not initGlasses() then
- os.display.setForeground(RED)
- print("ERROR: No OpenGlasses 2 component found!")
- print("Please ensure glasses are installed and linked.")
- os.display.setForeground(WHITE)
- return
- end
- -- Main loop
- while running do
- showMainMenu()
- local choice = getInput()
- if choice == "1" then
- widgetManager()
- elseif choice == "2" then
- object3DManager()
- elseif choice == "3" then
- print("\nSurface manager - coming soon!")
- os.system.sleep(2)
- elseif choice == "4" then
- radarControls()
- elseif choice == "5" then
- navigationSystem()
- elseif choice == "6" then
- quickActions()
- elseif choice == "7" then
- settingsInfo()
- elseif choice == "8" then
- clearAll()
- elseif choice == "9" then
- running = false
- end
- end
- os.display.setForeground(CYAN)
- print("\nThank you for using OpenGlasses 2 AR Control Suite!")
- os.display.setForeground(WHITE)
- end
- -- Run the program
- main()
Advertisement
Add Comment
Please, Sign In to add comment