edit file to clean this
This commit is contained in:
@ -1,18 +1,29 @@
|
||||
-- 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 info = {}
|
||||
|
||||
info = peripheral.getMethods(direction)
|
||||
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
|
||||
|
||||
-- list the methods from info
|
||||
local function getMethodsPeripheral(direction)
|
||||
local info = peripheral.getMethods(direction)
|
||||
return info
|
||||
end
|
||||
|
||||
local nbOfMethods = 0
|
||||
for methodName, methodInfo in pairs(info) do
|
||||
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...")
|
||||
@ -21,4 +32,20 @@ for methodName, methodInfo in pairs(info) do
|
||||
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 = getMethodsPeripheral(direction)
|
||||
if not info then
|
||||
print("No info found, exiting.")
|
||||
return
|
||||
end
|
||||
|
||||
displayMethodsPeripheral(info)
|
||||
|
||||
@ -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)
|
||||
|
||||
37
update.lua
37
update.lua
@ -1,3 +1,5 @@
|
||||
-- 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
|
||||
@ -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
|
||||
|
||||
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 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
|
||||
end
|
||||
if fileToUpdate == "exit" or fileToUpdate == "quit" then
|
||||
print("Sortie du programme.")
|
||||
return
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local DOWNLOAD_URL = "https://git.devconcept.pro/Neoblacks/scriptLua/raw/branch/main/" .. fileToUpdate
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user