Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(0,1)
- rsInput = rs.getBundledInput("back")
- -- colors for check if good spelling
- c1 = "white"
- c2 = "orange"
- c3 = "magenta"
- c4 = "lightBlue"
- c5 = "yellow"
- c6 = "lime"
- c7 = "pink"
- c8 = "gray"
- c9 = "lightGray"
- c10 = "cyan"
- c11 = "purple"
- c12 = "blue"
- c13 = "brown"
- c14 = "green"
- c15 = "red"
- c16 = "black"
- function convertValue1() -- change the color type by user into the color id.
- if value1 == "white" then value1 = 1
- elseif value1 == "orange" then value1 = 2
- elseif value1 == "magenta" then value1 = 4
- elseif value1 == "lightBlue" then value1 = 8
- elseif value1 == "yellow" then value1 = 16
- elseif value1 == "lime" then value1 = 32
- elseif value1 == "pink" then value1 = 64
- elseif value1 == "gray" then value1 = 128
- elseif value1 == "lightGray" then value1 = 256
- elseif value1 == "cyan" then value1 = 512
- elseif value1 == "purple" then value1 = 1024
- elseif value1 == "blue" then value1 = 2048
- elseif value1 == "brown" then value1 = 4096
- elseif value1 == "green" then value1 = 8192
- elseif value1 == "red" then value1 = 16384
- elseif value1 == "black" then value1 = 32768
- end
- end
- function printConfig()
- term.clear()
- term.setCursorPos(1,1)
- print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
- print("X Première utilisation X") -- First use
- print("X X")
- print("X Veuillez faire la configuration X") -- Please make the configuration of the color of your detectors.
- print("X des couleur de vos détecteurs. X")
- print("X X")
- print("X X")
- print("X X")
- print("X X")
- print("X Pour les couleurs en deux mots, écrivez les X") -- For color with 2 word, write them with a capital letter to the second. ex : lightBlue
- print("X avec une majuscule au second. ex : lightBlue X")
- print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
- end
- function checkConf() -- checking the configuration file
- while true do
- if fs.exists("tankConf.ini") == true then -- if the config file exist
- conf = fs.open("tankConf.ini", "r") -- open the file tankConf.ini in read-only mode
- water1 = tonumber(conf.readLine()) --read the first line and put it in var water1
- if water1 == nil then -- check if the var water1 is nil (if its nil then the conf file is "corrupted")
- conf.close() -- close reading of the file
- enterValue()
- else
- water2 = tonumber(conf.readLine()) -- read all line and put them on variables.
- water3 = tonumber(conf.readLine())
- lava1 = tonumber(conf.readLine())
- lava2 = tonumber(conf.readLine())
- lava3 = tonumber(conf.readLine())
- oil1 = tonumber(conf.readLine())
- oil2 = tonumber(conf.readLine())
- oil3 = tonumber(conf.readLine())
- fuel1 = tonumber(conf.readLine())
- fuel2 = tonumber(conf.readLine())
- fuel3 = tonumber(conf.readLine())
- conf.close() -- close reading file
- break
- end
- break
- else
- enterValue()
- end
- end
- end
- function enterValue()
- colorCount = 1
- conf = fs.open("tankConf.ini", "w") --open the config file or create it on write mode
- printConfig()
- value = "d'eau vide: " -- water tank empty
- writeColor()
- value = "d'eau ok: " -- water tank ok
- writeColor()
- value = "d'eau plein: " -- water tank full
- writeColor()
- value = "de lave vide: " -- lava tank empty
- writeColor()
- value = "de lave ok: " -- lava tank ok
- writeColor()
- value = "de lave plein: " -- lava tank full
- writeColor()
- value = "de pétrole vide: " -- oil tank empty
- writeColor()
- value = "de pétrole ok: " -- oil tank ok
- writeColor()
- value = "de pétrole plein:" -- oil tank full
- writeColor()
- value = "de fuel vide: " -- fuel tank empty
- writeColor()
- value = "de fuel ok: " -- fuel tank ok
- writeColor()
- value = "de fuel plein: " -- fuel tank full
- writeColor()
- conf.close()
- end
- function writeColor()
- while true do
- if colorCount ~= 13 then -- counting each colors given for break the loop
- term.setCursorPos(1,7)
- term.clearLine()
- print("X Couleur pour reservoir "..value.."X") -- Color for "..value.."
- term.setCursorPos(1,8)
- term.clearLine()
- write("X ->")
- value1 = io.read() -- below it check if the color is spelled correctly
- if value1 == c1 or value1 == c2 or value1 == c3 or value1 == c4 or value1 == c5 or value1 == c6 or value1 == c7 or value1 == c8 or value1 == c9 or value1 == c10 or value1 == c11 or value1 == c12 or value1 == c13 or value1 == c14 or value1 == c15 or value1 == c16 then
- convertValue1() -- send to the fonction vonvertValue1() for converting the variable into id of this color
- conf.writeLine(value1) -- write the id of the color given in the file
- colorCount = colorCount + 1 -- increment counter
- term.setCursorPos(1,9)
- term.clearLine()
- print("X X")
- break
- else
- term.setCursorPos(1,9)
- term.clearLine()
- print("X "..value1.." n'est pas une bonne couleur!") -- ..value.. is not a color
- end
- else
- conf.close()
- end
- end
- end
- function verifTank()
- rsInput = rs.getBundledInput("back")
- --Water check
- if colors.test(rsInput, water1) == true then
- term.setCursorPos(1,6)
- term.clearLine()
- print("X - Le réservoire d'eau est : Vide X") -- The water tank is : empty
- end
- if colors.test(rsInput, water3) == true then
- term.setCursorPos(1,6)
- term.clearLine()
- print("X - Le réservoire d'eau est : Plein X") -- The water tank is : full
- end
- if colors.test(rsInput, water2) == true and colors.test(rsInput, water1) == false then
- term.setCursorPos(1,6)
- term.clearLine()
- print("X - Le réservoire d'eau est : Ok X") -- The water tank is : ok
- end
- if colors.test(rsInput, water1) == false and colors.test(rsInput, water2) == false and colors.test(rsInput, water3) == false then
- term.setCursorPos(1,6)
- term.clearLine()
- print("X - Le réservoire d'eau est : ERREUR X") -- The water tank is : ERROR
- end
- -- end of water check
- sleep(1)
- -- Lava check
- if colors.test(rsInput, lava1) == true then
- term.setCursorPos(1,7)
- term.clearLine()
- print("X - Le reservoire de lave est : Vide X") -- The lava tank is : empty
- end
- if colors.test(rsInput, lava3) == true then
- term.setCursorPos(1,7)
- term.clearLine()
- print("X - Le reservoire de lave est : Plein X") -- The lava tank is : full
- end
- if colors.test(rsInput, lava2) == true and colors.test(rsInput, lava1) == false then
- term.setCursorPos(1,7)
- term.clearLine()
- print("X - Le reservoire de lave est : Ok X") -- The lava tank is : ok
- end
- if colors.test(rsInput, lava1) == false and colors.test(rsInput, lava2) == false and colors.test(rsInput, lava3) == false then
- term.setCursorPos(1,7)
- term.clearLine()
- print("X - Le reservoire de lave est : ERREUR X") -- The lava tank is : ERROR
- end
- -- end of lava check
- sleep(1)
- -- Oil check
- if colors.test(rsInput, oil1) == true then
- term.setCursorPos(1,8)
- term.clearLine()
- print("X - Le reservoire de pétrole est : Vide X") -- The oil tank is : empty
- end
- if colors.test(rsInput, oil3) == true then
- term.setCursorPos(1,8)
- term.clearLine()
- print("X - Le reservoire de pétrole est : Plein X") -- The oil tank is : full
- end
- if colors.test(rsInput, oil2) == true and colors.test(rsInput, oil1) == false then
- term.setCursorPos(1,8)
- term.clearLine()
- print("X - Le reservoire de pétrole est : Ok X") -- The oil tank is : ok
- end
- if colors.test(rsInput, oil1) == false and colors.test(rsInput, oil2) == false and colors.test(rsInput, oil3) == false then
- term.setCursorPos(1,8)
- term.clearLine()
- print("X - Le reservoire de pétrole est : ERREUR X") -- The oil tank is : ERROR
- end
- -- en of oil check
- sleep(1)
- -- fuel check
- if colors.test(rsInput, fuel1) == true then
- term.setCursorPos(1,9)
- term.clearLine()
- print("X - Le reservoire de fuel est : Vide X") -- The fuel tank is : empty
- end
- if colors.test(rsInput, fuel3) == true then
- term.setCursorPos(1,9)
- term.clearLine()
- print("X - Le reservoire de fuel est : Plein X") -- The fuel tank is : full
- end
- if colors.test(rsInput, fuel2) == true and colors.test(rsInput, colors.pink) == false then
- term.setCursorPos(1,9)
- term.clearLine()
- print("X - Le reservoire de fuel est : Ok X") -- The fuel tank is : ok
- end
- if colors.test(rsInput, fuel1) == false and colors.test(rsInput, fuel2) == false and colors.test(rsInput, fuel3) == false then
- term.setCursorPos(1,9)
- term.clearLine()
- print("X - Le reservoire de fuel est : ERREUR X") -- The fuel tank is : ERROR
- end
- -- end of fuel check
- loop()
- end
- function loop()
- while true do
- event = os.pullEvent()
- if event == "redstone" then -- if there is some change in redstone it go to verify all the tanks
- verifTank()
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- checkConf()
- term.clear()
- term.setCursorPos(1,1)
- print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
- print("X X")
- print("X Controle des niveaux X") -- Tank control
- print("X X")
- print("X X")
- print("X - Le réservoire d'eau est : X") -- The water tank is :
- print("X - Le reservoire de lave est : X") -- The lava tank is :
- print("X - Le reservoire de pétrole est : X") -- The oil tank is :
- print("X - Le reservoire de fuel est : X") -- The fuel tank is :
- print("X X")
- print("X X")
- print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
- sleep(2)
- verifTank()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement