41 lines
1.2 KiB
Lua
41 lines
1.2 KiB
Lua
-- 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
|
|
if response then
|
|
local file = io.open(scriptLuaPath, "wb")
|
|
file:write(response.readAll())
|
|
file:close()
|
|
print("Fichier téléchargé avec succès vers: " .. dest)
|
|
else
|
|
print("Erreur lors du téléchargement du fichier")
|
|
end
|
|
end
|
|
|
|
|
|
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 false
|
|
end
|
|
return true
|
|
end
|
|
|
|
|
|
--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)
|