edit file to clean this

This commit is contained in:
2025-07-30 14:01:15 +02:00
parent 946cbad670
commit 7eb035c116
3 changed files with 75 additions and 37 deletions

View File

@ -1,24 +1,51 @@
-- ask direction to get methods of a peripheral
print("Enter the direction of the peripheral (left, right, top, bottom, front, back):")
local direction = io.read()
if not direction or direction == "quit" or direction == "exit" then
local function getPeripheralDirection()
print("Enter the direction of the peripheral (left, right, top, bottom, front, back):")
local direction = io.read()
if not direction or direction == "quit" or direction == "exit" then
print("No direction specified, exiting.")
return
end
return direction
end
local function checkDirectionIsValid(direction)
if not direction or direction == "quit" or direction == "exit" then
print("No direction specified, exiting.")
return false
end
return true
end
local function getMethodsPeripheral(direction)
local info = peripheral.getMethods(direction)
return info
end
local function displayMethodsPeripheral(info)
local nbOfMethods = 0
for methodName, methodInfo in pairs(info) do
nbOfMethods = nbOfMethods + 1
if nbOfMethods > 10 then
print("Too many methods, please press a key to continue...")
event, p1 = os.pullEvent("key")
nbOfMethods = 0
term.clear()
end
print(methodName .. ' ' .. methodInfo)
end
end
-- main
local direction = getPeripheralDirection()
local isDirectionIsNotEmpty = checkDirectionIsValid(direction)
if not isDirectionIsNotEmpty then
print("No direction specified, exiting.")
return
end
local info = {}
info = peripheral.getMethods(direction)
-- list the methods from info
local nbOfMethods = 0
for methodName, methodInfo in pairs(info) do
nbOfMethods = nbOfMethods + 1
if nbOfMethods > 10 then
print("Too many methods, please press a key to continue...")
event, p1 = os.pullEvent("key")
nbOfMethods = 0
term.clear()
end
print(methodName .. ' ' .. methodInfo)
local info = getMethodsPeripheral(direction)
if not info then
print("No info found, exiting.")
return
end
displayMethodsPeripheral(info)

View File

@ -1 +1,3 @@
test
-- File to get info about Powah reactor
-- Info need to have:
-- MaxEnergyStorage, ActualTemp, Storage of uraninite, Storage of Coal, Ice, Redstone (+ value about property of this item)

View File

@ -1,6 +1,8 @@
-- Script pour télécharger un fichier depuis un repo git (CC TWEAKED Minecraft)
local function downloadFile(url, dest)
local response = http.get(url)
local scriptLuaPath = "scriptLua/" .. dest
local scriptLuaPath = "scriptLua/" .. dest
if response then
local file = io.open(scriptLuaPath, "wb")
file:write(response.readAll())
@ -11,21 +13,28 @@ local function downloadFile(url, dest)
end
end
-- Demander à l'utilisateur la destination du fichier
print("Entrez le chemin de destination du fichier (ex: script.lua):")
local fileToUpdate = io.read() -- Lire l'entrée de l'utilisateur
-- Si l'utilisateur tape un espace dans le nom le remplacer par underscore
fileToUpdate = fileToUpdate:gsub(" ", "_")
-- Vérifier que l'utilisateur a bien entré quelque chose
if fileToUpdate == nil or fileToUpdate == "" then
print("Aucune destination spécifiée, sortie du programme.")
return
end
if fileToUpdate == "exit" or fileToUpdate == "quit" then
print("Sortie du programme.")
return
local function getFileName()
print("Entrez le chemin de destination du fichier (ex: script.lua):")
local fileToUpdate = io.read()
fileToUpdate = fileToUpdate:gsub(" ", "_")
return fileToUpdate
end
local DOWNLOAD_URL = "https://git.devconcept.pro/Neoblacks/scriptLua/raw/branch/main/" .. fileToUpdate
local function checkFileNameIsNotEmpty(fileName)
if fileName == nil or fileName == "" or fileName == "exit" or fileName == "quit" then
print("Aucune destination spécifiée, sortie du programme.")
return false
end
return true
end
downloadFile(DOWNLOAD_URL, fileToUpdate)
--main
local fileName = getFileName()
local fileNameIsNotEmpty = checkFileNameIsNotEmpty(fileName) -- boolean
if not fileNameIsNotEmpty then
return
end
local DOWNLOAD_URL = "https://git.devconcept.pro/Neoblacks/scriptLua/raw/branch/main/" .. fileName
downloadFile(DOWNLOAD_URL, fileName)