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("label set Rubi")
- shell.run("clear")
- local version = 1.0
- local ItemsList = {}
- local ActiveItemList = {}
- local MenuBackgroundColor = colors.fromRGB(0, 48, 73)
- local MenuTextColor = colors.fromRGB(247, 127, 0)
- -----------------------------------------------------------------------------------
- local function GUInit()
- SetButton("Serveur", ServerButtonfunction, 3, 18, 3, 5,colors.fromRGB(85,195,186),colors.fromRGB(236, 240, 241),"ServerMenu")
- SetButton("Client", ClientButtonfunction, 21, 36, 3, 5,colors.fromRGB(253, 179, 20),colors.fromRGB(236, 240, 241),"ClientMenu")
- SetButton("QuarryButton", QuarryButtonfunction, 2, 9, 3, 5,colors.fromRGB(132, 83, 26),colors.fromRGB(236, 240, 241),"Quarry")
- SetButton("FarmButton", FarmButtonfunction, 2, 9, 6, 8,colors.fromRGB(112, 140, 0),colors.fromRGB(236, 240, 241),"Farm")
- SetButton("ReturnBack", MainMenu, 1, 6, 13, 13,colors.fromRGB(252, 0, 0),colors.fromRGB(212, 212, 212),"retour")
- end
- function SetButton(name, func, xmin, xmax, ymin, ymax,bcolor,tcolor,text)
- ItemsList[name] = {}
- ItemsList[name]["function"] = func
- ItemsList[name]["active"] = false
- 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
- function SetText(name, xmin, xmax, ymin, ymax,bcolor,tcolor,text)
- ItemsList[name] = {}
- ItemsList[name]["active"] = false
- 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
- function fill(text, color,textcolor, bData)
- term.setTextColor(textcolor)
- term.setBackgroundColor(color)
- local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
- local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
- for j = bData["ymin"], bData["ymax"] do
- term.setCursorPos(bData["xmin"], j)
- if j == yspot then
- for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
- if k == xspot then
- term.write(text)
- else
- term.write(" ")
- end
- end
- else
- for i = bData["xmin"], bData["xmax"] do
- term.write(" ")
- end
- end
- end
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- end
- function InitiateButton(MenuButton)
- ActiveItemList = MenuButton
- for k,Button in pairs(MenuButton) do
- fill(Button["text"],Button["backcolor"],Button["textcolor"],Button)
- end
- if ItemsList["Return"]["function"] ~= nil then
- local Button = ItemsList["Return"]
- fill(Button["text"],Button["backcolor"],Button["textcolor"],Button)
- ActiveItemList["Return"] = ItemsList["Return"]
- end
- end
- -------------------------------------------------------------------
- function ServerButtonfunction()
- Title()
- ItemsList["ReturnBack"]["function"] = MainMenu
- ActiveItemList["ReturnBack"] = ItemsList["ReturnBack"]
- Draw()
- end
- function ClientButtonfunction()
- Title()
- ItemsList["ReturnBack"]["function"] = MainMenu
- ActiveItemList["QuarryButton"] = ItemsList["QuarryButton"]
- ActiveItemList["FarmButton"] = ItemsList["FarmButton"]
- ActiveItemList["ReturnBack"] = ItemsList["ReturnBack"]
- Draw()
- end
- function QuarryButtonfunction()
- Title()
- ItemsList["ReturnBack"]["function"] = ClientButtonfunction
- ActiveItemList["ReturnBack"] = ItemsList["ReturnBack"]
- Draw()
- end
- function FarmButtonfunction()
- Title()
- ItemsList["ReturnBack"]["function"] = ClientButtonfunction
- ActiveItemList["ReturnBack"] = ItemsList["ReturnBack"]
- Draw()
- end
- -------------------------------------------------------------------
- ----------------------Menu-----------------------------------------
- -------------------------------------------------------------------
- function Title()
- ActiveItemList = {}
- term.setBackgroundColor(MenuBackgroundColor)
- term.setTextColor(MenuTextColor)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Programme Anita V")
- term.setTextColor(colors.fromRGB(247, 127, 0))
- term.write(version)
- 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"]
- Draw()
- end
- -------------------------------------------------------------------
- ----------------------Feature--------------------------------------
- -------------------------------------------------------------------
- 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
- function Draw()
- for k,Button in pairs(ActiveItemList) do
- fill(Button["text"],Button["backcolor"],Button["textcolor"],Button)
- end
- end
- local function LeftButton()
- write("Fuck you")
- end
- -----------------------------------------------------------------------------------
- ------------------------------------Quarry---------------------------------------
- -----------------------------------------------------------------------------------
- Pos = {0,0,0}
- shell.run("label set " .. Pos[1])
- -----------------------------------------------------------------------------------
- -------------------------------Main------------------------------------------------
- -----------------------------------------------------------------------------------
- GUInit()
- inputCoroutine = coroutine.create(Com)
- coroutine.resume(inputCoroutine)
- MainMenu()
- while true do
- myEvent = { os.pullEvent() }
- if myEvent[1] == "mouse_click" then
- for k,Element in pairs(ActiveItemList) do
- if 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
- fill(Element["text"],colors.fromRGB(46, 204, 113),Element["textcolor"],Element)
- sleep(0.4)
- Element["function"]()
- else
- shell.run("label set Fail " .. Element["text"])
- end
- end
- end
- end
- if myEvent[1] == "rednet_message" or myEvent[1] == "timer" then
- coroutine.resume( comCoroutine, unpack( myEvent ) )
- end
- end
Add Comment
Please, Sign In to add comment