edit file to clean this
This commit is contained in:
@ -1,24 +1,51 @@
|
|||||||
-- ask direction to get methods of a peripheral
|
local function getPeripheralDirection()
|
||||||
print("Enter the direction of the peripheral (left, right, top, bottom, front, back):")
|
print("Enter the direction of the peripheral (left, right, top, bottom, front, back):")
|
||||||
local direction = io.read()
|
local direction = io.read()
|
||||||
if not direction or direction == "quit" or direction == "exit" then
|
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.")
|
print("No direction specified, exiting.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local info = {}
|
local info = getMethodsPeripheral(direction)
|
||||||
|
if not info then
|
||||||
info = peripheral.getMethods(direction)
|
print("No info found, exiting.")
|
||||||
|
return
|
||||||
-- 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)
|
|
||||||
end
|
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)
|
||||||
|
|||||||
41
update.lua
41
update.lua
@ -1,6 +1,8 @@
|
|||||||
|
-- Script pour télécharger un fichier depuis un repo git (CC TWEAKED Minecraft)
|
||||||
|
|
||||||
local function downloadFile(url, dest)
|
local function downloadFile(url, dest)
|
||||||
local response = http.get(url)
|
local response = http.get(url)
|
||||||
local scriptLuaPath = "scriptLua/" .. dest
|
local scriptLuaPath = "scriptLua/" .. dest
|
||||||
if response then
|
if response then
|
||||||
local file = io.open(scriptLuaPath, "wb")
|
local file = io.open(scriptLuaPath, "wb")
|
||||||
file:write(response.readAll())
|
file:write(response.readAll())
|
||||||
@ -11,21 +13,28 @@ local function downloadFile(url, dest)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Demander à l'utilisateur la destination du fichier
|
|
||||||
print("Entrez le chemin de destination du fichier (ex: script.lua):")
|
local function getFileName()
|
||||||
local fileToUpdate = io.read() -- Lire l'entrée de l'utilisateur
|
print("Entrez le chemin de destination du fichier (ex: script.lua):")
|
||||||
-- Si l'utilisateur tape un espace dans le nom le remplacer par underscore
|
local fileToUpdate = io.read()
|
||||||
fileToUpdate = fileToUpdate:gsub(" ", "_")
|
fileToUpdate = fileToUpdate:gsub(" ", "_")
|
||||||
-- Vérifier que l'utilisateur a bien entré quelque chose
|
return fileToUpdate
|
||||||
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
|
|
||||||
end
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user