ElijahCrafter

Hardware Test

Dec 6th, 2025
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.98 KB | Source Code | 0 0
  1. -- Hardware Effects Test Script
  2. -- Tests GPU resolution limits, RAM concurrency, and monitor API
  3.  
  4. print("=== Hardware Effects Test ===")
  5. print("")
  6.  
  7. -- Test 1: Check parallel API (RAM)
  8. print("--- RAM Test (Concurrent Tasks) ---")
  9. local maxTasks = parallel.getMaxConcurrent()
  10. print("Max concurrent tasks: " .. maxTasks)
  11. print("")
  12.  
  13. -- Test 2: Find and test monitor
  14. print("--- Monitor Resolution Test ---")
  15. local monitor = peripheral.find("monitor")
  16. if monitor then
  17.     -- Get current size
  18.     local w, h = monitor.getSize()
  19.     print("Current size: " .. w .. "x" .. h)
  20.    
  21.     -- Get max resolution from GPU
  22.     local maxW, maxH = monitor.getMaxResolution()
  23.     print("Max resolution (GPU limit): " .. maxW .. "x" .. maxH)
  24.    
  25.     -- Get current resolution
  26.     local resW, resH = monitor.getResolution()
  27.     print("Current resolution: " .. resW .. "x" .. resH)
  28.    
  29.     -- Try setting a custom resolution
  30.     print("")
  31.     print("Setting resolution to 40x20...")
  32.     monitor.setResolution(40, 20)
  33.    
  34.     local newW, newH = monitor.getResolution()
  35.     print("New resolution: " .. newW .. "x" .. newH)
  36.    
  37.     -- Test monitor display
  38.     monitor.clear()
  39.     monitor.setCursorPos(1, 1)
  40.     monitor.setTextColor(colors.lime)
  41.     monitor.write("Resolution Test")
  42.     monitor.setCursorPos(1, 2)
  43.     monitor.setTextColor(colors.white)
  44.     monitor.write("Size: " .. newW .. "x" .. newH)
  45.    
  46.     -- Reset resolution
  47.     print("Resetting resolution...")
  48.     monitor.resetResolution()
  49.     local resetW, resetH = monitor.getResolution()
  50.     print("Reset resolution: " .. resetW .. "x" .. resetH)
  51. else
  52.     print("No monitor found! Connect a monitor via cable.")
  53. end
  54. print("")
  55.  
  56. -- Test 3: Storage capacity (HDD)
  57. print("--- Storage Test (HDD) ---")
  58. if fs.getCapacity then
  59.     local capacity = fs.getCapacity()
  60.     local used = fs.getUsed and fs.getUsed() or 0
  61.     print("Storage capacity: " .. capacity .. " bytes")
  62.     print("Storage used: " .. used .. " bytes")
  63.     print("Storage free: " .. (capacity - used) .. " bytes")
  64. else
  65.     print("Storage API not available")
  66. end
  67. print("")
  68.  
  69. -- Test 4: Parallel task batching
  70. print("--- Parallel Task Batching Test ---")
  71. local taskCount = 0
  72. local function makeTask(id)
  73.     return function()
  74.         taskCount = taskCount + 1
  75.         -- Simulate work
  76.         sleep(0.1)
  77.     end
  78. end
  79.  
  80. -- Create more tasks than RAM allows
  81. local tasks = {}
  82. for i = 1, 6 do
  83.     table.insert(tasks, makeTask(i))
  84. end
  85.  
  86. print("Running 6 parallel tasks (RAM limit: " .. maxTasks .. ")...")
  87. parallel.waitForAll(table.unpack(tasks))
  88. print("Completed " .. taskCount .. " tasks")
  89. print("")
  90.  
  91. -- Test 5: List all peripherals
  92. print("--- Connected Peripherals ---")
  93. local names = peripheral.getNames()
  94. if #names > 0 then
  95.     for i, name in ipairs(names) do
  96.         local pType = peripheral.getType(name)
  97.         print("  " .. name .. " (" .. pType .. ")")
  98.     end
  99. else
  100.     print("  No peripherals connected")
  101. end
  102. print("")
  103.  
  104. print("=== Test Complete ===")
  105.  
Advertisement
Add Comment
Please, Sign In to add comment