Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Liste tous les périphériques connectés
- local periphs = peripheral.getNames()
- print("Detected peripherals:")
- for i, name in ipairs(periphs) do
- local pType = peripheral.getType(name)
- print(i .. ". " .. name .. " (" .. pType .. ")")
- end
- -- Demande à l'utilisateur de choisir un périphérique
- print()
- write("Enter the number of the peripheral to inspect: ")
- local choice = tonumber(read())
- if not choice or choice < 1 or choice > #periphs then
- print("Invalid choice.")
- return
- end
- local selectedName = periphs[choice]
- local selectedPeripheral = peripheral.wrap(selectedName)
- if not selectedPeripheral then
- print("Failed to wrap peripheral: " .. selectedName)
- return
- end
- -- Récupère la liste des fonctions du périphérique
- local functions = {}
- for k, v in pairs(selectedPeripheral) do
- if type(v) == "function" then
- table.insert(functions, k)
- end
- end
- -- Trie les fonctions par ordre alphabétique
- table.sort(functions)
- -- Affiche la liste des fonctions
- print()
- print("Functions available on " .. selectedName .. ":")
- for i, fn in ipairs(functions) do
- print("- " .. fn)
- end
- -- Demande à l'utilisateur s'il veut sauvegarder la liste
- print()
- write("Enter a filename to save the list (or leave blank to skip): ")
- local filename = read()
- if filename ~= "" then
- local file = fs.open(filename, "w")
- file.writeLine("Functions available on " .. selectedName .. ":")
- for i, fn in ipairs(functions) do
- file.writeLine("- " .. fn)
- end
- file.close()
- print("Function list saved to '" .. filename .. "'")
- else
- print("Skipped saving.")
- end
Advertisement
Add Comment
Please, Sign In to add comment