Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------Main------
- shell.run("rm Anita/API/rgb")
- shell.run("pastebin get BCSWghjR Anita/API/rgb")
- os.loadAPI("Anita/API/rgb")
- shell.run("rm Anita/API/ToolBox")
- shell.run("pastebin get iiqvdU1J Anita/API/ToolBox")
- os.loadAPI("Anita/API/ToolBox")
- shell.run("label set Rubi")
- shell.run("clear")
- shell.run("rm Anita/Anitas.last")
- local version = "1.0"
- ItemsList = {}
- local ActiveItemList = {}
- local MenuBackgroundColor = colors.fromRGB(0, 48, 73)
- local MenuTextColor = colors.fromRGB(247, 127, 0)
- Page = 0
- CurrentProgramme = "none"
- LastTime = os.time()
- CurrentFunction = nil
- function TestScript()
- CurrentProgramme = "Quarry"
- end
- function PageNext() if Page < 1 then Page = Page + 1 end QuarryButtonfunction() end
- function PageBack() if Page > 0 then Page = Page - 1 end QuarryButtonfunction() end
- -----------------------------------------------------------------------------------
- function GUInit()
- SetItem("Serveur", ServerButtonfunction, 3, 18, 3, 5,colors.fromRGB(85,195,186),colors.fromRGB(236, 240, 241),"ServerMenu")
- SetItem("Client", ClientButtonfunction, 21, 36, 3, 5,colors.fromRGB(253, 179, 20),colors.fromRGB(236, 240, 241),"ClientMenu")
- SetItem("QuarryButton", QuarryButtonfunction, 2, 9, 3, 5,colors.fromRGB(132, 83, 26),colors.fromRGB(236, 240, 241),"Quarry")
- SetItem("FarmButton", FarmButtonfunction, 2, 9, 7, 9,colors.fromRGB(112, 140, 0),colors.fromRGB(236, 240, 241),"Farm")
- SetItem("ReturnBack", MainMenu, 1, 6, 13, 13,colors.fromRGB(252, 0, 0),colors.fromRGB(212, 212, 212),"retour")
- SetItem("QuarryStart", TestScript, 35, 39, 13, 13,colors.blue,colors.fromRGB(212, 212, 212),"Start")
- SetItem("Suivant", PageNext, 26, 33, 13, 13,colors.purple,colors.fromRGB(212, 212, 212),"Suivant")
- SetItem("Arriere", PageBack, 8, 14, 13, 13,colors.purple,colors.fromRGB(212, 212, 212),"Arrière")
- end
- -----------------------------------------------------------------------------------
- function SetItem(name, func, xmin, xmax, ymin, ymax,bcolor,tcolor,text)
- ItemsList[name] = {}
- ItemsList[name]["function"] = func
- ItemsList[name]["xmin"] = xmin
- ItemsList[name]["ymin"] = ymin
- ItemsList[name]["xmax"] = xmax
- ItemsList[name]["ymax"] = ymax
- ItemsList[name]["backcolor"] = bcolor
- ItemsList[name]["textcolor"] = tcolor
- ItemsList[name]["text"] = text
- end
- ------------------------Button----------------------------------
- function ServerButtonfunction()
- Title()
- ItemsList["ReturnBack"]["function"] = MainMenu
- ActiveItemList["ReturnBack"] = ItemsList["ReturnBack"]
- ToolBox.Draw(ActiveItemList)
- end
- function ClientButtonfunction()
- Title()
- ItemsList["ReturnBack"]["function"] = MainMenu
- ActiveItemList["QuarryButton"] = ItemsList["QuarryButton"]
- ActiveItemList["FarmButton"] = ItemsList["FarmButton"]
- ActiveItemList["ReturnBack"] = ItemsList["ReturnBack"]
- ToolBox.Draw(ActiveItemList)
- end
- function QuarryButtonfunction()
- Title()
- local TurtleTable = ToolBox.AnitaRead()
- local TurtlePos = TurtleTable["Position"]
- local TurtleDir = TurtleTable["Orientation"]
- local TurtleSize = TurtleTable["Size"]
- ActiveItemList["QuarryPos"] = ItemsList["QuarryPos"]
- ItemsList["ReturnBack"]["function"] = ClientButtonfunction
- ActiveItemList["ReturnBack"] = ItemsList["ReturnBack"]
- ActiveItemList["QuarryStart"] = ItemsList["QuarryStart"]
- ActiveItemList["Suivant"] = ItemsList["Suivant"]
- ActiveItemList["Arriere"] = ItemsList["Arriere"]
- TurtleSize[1] = 100
- TurtleSize[2] = 100
- TurtleSize[3] = 100
- if Page == 0 then
- term.setCursorPos(1,3)
- local QuarryMenuColor = colors.fromRGB(236, 240, 241)
- term.setBackgroundColor(MenuBackgroundColor)
- ColorList= {QuarryMenuColor,colors.fromRGB(192, 57, 43),colors.white,colors.fromRGB(46, 204, 113),colors.white,colors.fromRGB(52, 152, 219),colors.white,colors.orange,colors.white}
- TextList = {"Pos actuelle : ","x:",TurtlePos[1]," y:",TurtlePos[2]," z:",TurtlePos[3]," dir: ",TurtleDir}
- ToolBox.WriteText(ColorList,TextList)
- term.setCursorPos(1,4)
- term.setBackgroundColor(MenuBackgroundColor)
- ColorList= {QuarryMenuColor,colors.fromRGB(192, 57, 43),colors.white,colors.fromRGB(46, 204, 113),colors.white,colors.fromRGB(52, 152, 219),colors.white}
- TextList = {"WorkZone : ", "L:",TurtleSize[1] , " l:",TurtleSize[2] ," h:" ,TurtleSize[3]}
- ToolBox.WriteText(ColorList,TextList)
- term.setCursorPos(1,5)
- ColorList= {QuarryMenuColor ,colors.cyan}
- TextList = {"Volume : " ,TurtleSize[1]*TurtleSize[2]*TurtleSize[3]}
- ToolBox.WriteText(ColorList,TextList)
- term.setCursorPos(1,6)
- ColorList= {QuarryMenuColor ,colors.cyan,colors.white}
- TextList = {"Block Miné : " , TurtleTable["Block miné"], " Block Miné"}
- ToolBox.WriteText(ColorList,TextList)
- term.setCursorPos(1,7)
- term.setBackgroundColor(MenuBackgroundColor)
- term.setTextColor(MenuTextColor)
- term.write("---------------------------------------")
- term.setCursorPos(1,8)
- term.setBackgroundColor(MenuBackgroundColor)
- term.setTextColor(colors.white)
- ColorList= {QuarryMenuColor,colors.cyan,QuarryMenuColor,colors.green}
- TextList = {"Carburant : ",TurtleTable["Fuel Level"],"/",TurtleTable["Total Fuel"]}
- ToolBox.WriteText(ColorList,TextList)
- term.setCursorPos(1,9)
- term.setBackgroundColor(MenuBackgroundColor)
- term.setTextColor(colors.white)
- term.write("Mouvement : " .. TurtleTable["Mouvement"])
- elseif Page == 1 then
- term.setCursorPos(1,3)
- term.setBackgroundColor(MenuBackgroundColor)
- term.setTextColor(colors.white)
- if TurtleTable["EnderChest"] ~= 0 then
- term.write("EnderChest : slot n°" .. TurtleTable["EnderChest"])
- else
- term.write("EnderChest : Désactivé")
- end
- end
- ToolBox.Draw(ActiveItemList)
- term.setCursorPos(1,10)
- term.setBackgroundColor(MenuBackgroundColor)
- term.setTextColor(MenuTextColor)
- term.write("___________________________________________")
- term.setCursorPos(1,12)
- term.setBackgroundColor(MenuBackgroundColor)
- term.setTextColor(MenuTextColor)
- term.write("---------------------------------------")
- Pourcentage = 68 ---ToolBox.AnitaRead("Progression")
- PourTrente = ToolBox.round((Pourcentage / 100)*39)
- local text = "Progression " .. Pourcentage .." % "
- for i=1,39 do
- local pixelcolor = colors.black
- if i < (PourTrente+1) then
- pixelcolor = colors.green
- else
- pixelcolor = colors.gray
- end
- if i > 11 and i < 28 then
- term.setBackgroundColor(pixelcolor)
- term.setTextColor(colors.white)
- if (i-11)<string.len(text) then
- term.write(string.sub(text, (i-11)), (i-11))
- end
- else
- paintutils.drawPixel(i, 11, pixelcolor)
- end
- end
- end
- function FarmButtonfunction()
- Title()
- ItemsList["ReturnBack"]["function"] = ClientButtonfunction
- ActiveItemList["ReturnBack"] = ItemsList["ReturnBack"]
- ToolBox.Draw(ActiveItemList)
- end
- -------------------------------------------------------------------
- ----------------------Menu-----------------------------------------
- -------------------------------------------------------------------
- function Title()
- ActiveItemList = {}
- term.setBackgroundColor(MenuBackgroundColor)
- term.setTextColor(MenuTextColor)
- term.clear()
- term.setCursorPos(1,1)
- local time = os.time()
- local formattedTime = textutils.formatTime(time, false)
- term.write("Programme Anita V")
- term.write(version)
- for i = 1, (22 - string.len(version) - string.len(tostring(formattedTime))) do
- term.write(" ")
- end
- term.setTextColor(colors.white)
- term.write(formattedTime)
- term.setCursorPos(1,2)
- term.setTextColor(MenuTextColor)
- term.write("---------------------------------------")
- term.setTextColor(colors.black)
- end
- function MainMenu()
- Title()
- ActiveItemList["Serveur"] = ItemsList["Serveur"]
- ActiveItemList["Client"] = ItemsList["Client"]
- ToolBox.Draw(ActiveItemList)
- end
- -------------------------------------------------------------------
- ----------------------Feature--------------------------------------
- -------------------------------------------------------------------
- local function QuarryTurn()
- local Direction = ToolBox.AnitaRead("Last turn")
- shell.run('label set ' .. tostring(Direction))
- EmptySpace = false
- for i = 1,16 do
- if turtle.getItemCount(i)==0 then
- EmptySpace = true
- end
- end
- if EmptySpace == false then
- Home = true
- end
- if Direction then
- ToolBox.MoveLeft()
- turtle.digDown()
- turtle.digUp()
- ToolBox.MoveForward()
- turtle.digDown()
- turtle.digUp()
- ToolBox.MoveLeft()
- else
- ToolBox.MoveRight()
- turtle.digDown()
- turtle.digUp()
- ToolBox.MoveForward()
- turtle.digDown()
- turtle.digUp()
- ToolBox.MoveRight()
- end
- Direction = not Direction
- ToolBox.AnitaWrite("Last turn", Direction)
- end
- function Quarry()
- largeur = 7
- longueur = 7
- while true do
- if CurrentProgramme == "Quarry" then
- ToolBox.MoveDown()
- ToolBox.MoveDown()
- turtle.digDown()
- for i = 1,(largeur-1) do
- for i = 1,(longueur-1) do
- ToolBox.MoveForward()
- turtle.digDown()
- turtle.digUp()
- end
- QuarryTurn()
- end
- for i = 1,(longueur-1) do
- ToolBox.MoveForward()
- turtle.digDown()
- turtle.digUp()
- end
- ToolBox.AnitaWrite("Last turn", false)
- ToolBox.MoveRight()
- for i = 1,(largeur-1) do
- ToolBox.MoveForward()
- end
- ToolBox.MoveRight()
- ToolBox.MoveForward()
- end
- sleep(0.05)
- end
- end
- local function Com()
- while true do
- local sender, message = rednet.receive()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(99,99)
- print(message)
- rednet.send(sender, "Réponse")
- end
- end
- local function UI()
- while true do
- local myEvent = { os.pullEvent() }
- if myEvent[1] == "mouse_click" then
- for k,Element in pairs(ActiveItemList) do
- if Element["function"] ~= nil and myEvent[3] >= Element["xmin"] and myEvent[3] < Element["xmax"] and myEvent[4] >= Element["ymin"] and myEvent[4] <= Element["ymax"] then
- if Element["function"] ~= nil then
- Element["function"]()
- CurrentFunction = Element["function"]
- end
- end
- end
- end
- end
- end
- local function Update()
- local time = os.time()
- term.setCursorPos(1,1)
- term.setTextColor(MenuTextColor)
- term.setBackgroundColor(MenuBackgroundColor)
- term.setCursorPos(1,1)
- term.clearLine()
- local time = os.time()
- local formattedTime = textutils.formatTime(time, false)
- term.write("Programme Anita V")
- term.write(version)
- for i = 1, (22 - string.len(version) - string.len(tostring(formattedTime))) do
- term.write(" ")
- end
- term.setTextColor(colors.white)
- term.write(formattedTime)
- sleep(0.05)
- end
- local function Time()
- while true do
- if os.time() ~= LastTime then
- if CurrentFunction ~= nil then
- CurrentFunction()
- end
- LastTime = os.time()
- Update()
- else
- sleep(0.05)
- end
- end
- end
- -----------------------------------------------------------------------------------
- -------------------------------Main------------------------------------------------
- -----------------------------------------------------------------------------------
- GUInit()
- MainMenu()
- parallel.waitForAny(Quarry,UI,Com,Time)
Add Comment
Please, Sign In to add comment