Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Credits: ---
- --- Made by ComputerCraftFan11 (IGN: xXm0dzXx)
- --- Please do not steal without giving credits
- --- Functions:
- --- getX() returns the cursor's X
- --- getY() returns the cursor's Y
- --- isAt(x, y) returns true if the cursor is at the x, y
- --- newFrame(x, y, length, width) will make a frame
- --- See post for more
- --- FAQ ---
- --- How to add a new program ?
- --- New programs are added automatically if they are in windows/programs/start
- --- How to add a new shortcut/program on the desktop ?
- --- Desktop programs are stored in windows/programs
- --- I made a folder and its not showing up, why ?
- --- Only files show up, folders do not. To make a folder you'll have to manually make a program that opens the folder or you will have to wait.
- --- How do I contact you ?
- --- My IGN (In-Game-Name) is xXm0dzXx, or you can contact my forums accounts:
- --- Computercraft.info : ComputerCraftFan11
- --- minecraftforum.net : ComputerCraftFan1
- --- CODE ---
- local x, y = term.getSize()
- local currentX = 1;
- local currentY = 1;
- local Cursor = ">";
- local pressed = false;
- local running = "";
- local pirated = false; --for a server to prevent piracy
- local path = "";
- local programCap = 0
- local isStart = false
- local oldkey = 0
- if not fs.exists("windows") then
- fs.makeDir("windows")
- fs.makeDir("windows/programs")
- fs.makeDir("windows/programs/start")
- end
- --- API ---
- function getX()
- return currentX
- end
- function getY()
- return currentY
- end
- function isAt(param1, param2)
- if currentX == param1 and currentY == param2 then
- return true
- else
- return false
- end
- end
- function changeCursor(param1)
- Cursor = param1
- end
- function moveTo(param1, param2)
- currentX = param1
- currentY = param2
- end
- function newFrame(param1, param2, param3, param4)
- local length = 0
- local width = 1
- local sized = ""
- for i=1,param3 do
- term.setCursorPos(param1 + length, param2)
- if length == 0 then
- write("+-")
- sized = sized.. "+"
- elseif length == param3-1 then
- write("-+")
- sized = sized.. "-+"
- else
- write("-")
- sized = sized.. "-"
- end
- length = length+1
- end
- for i=1,param4 do
- term.setCursorPos(param1, param2 + width)
- write("|")
- term.setCursorPos(param1 + length, param2 + width)
- write("|")
- width = width+1
- end
- term.setCursorPos(param1, param2 + width - 1)
- write(sized)
- end
- function getKeys()
- return oldkey
- end
- local history = ""
- function winRead(param1, param2)
- term.setCursorPos(param1, param2)
- if(getKeys() == 28) then
- history = ""
- else
- history = history.. "" ..getKeys()
- write(history)
- end
- end
- --- END OF API ---
- function start()
- newLine(1, y-10, "----------+")
- files = fs.list("windows/programs/start")
- for n=1,#files do
- if not fs.isDir("windows/programs/start" ..files[n])then
- local x2,y2 = term.getCursorPos()
- -- if programCap < 7 then
- newButton(1, y2+1, "" ..files[n], files[n], "windows/programs/start/")
- -- programCap = programCap +1
- -- end
- end
- end
- newButton(1, y-2, "Shutdown", "shutdown", "/rom/programs/")
- newLine(11, y-9, "|")
- newLine(11, y-8, "|")
- newLine(11, y-7, "|")
- newLine(11, y-6, "|")
- newLine(11, y-5, "|")
- newLine(11, y-4, "|")
- newLine(11, y-3, "|")
- newLine(11, y-2, "|")
- end
- function newButton(x1, y1, title, do22, path2)
- term.setCursorPos(x1+1, y1)
- write(title)
- if pressed == true then
- if currentX == x1 then
- if currentY == y1 then
- path = path2
- if do22 == "start" and isStart == true then
- isStart = false
- elseif do22 == "start" and isStart == false then
- isStart = true
- else
- running = do22
- isStart = false
- end
- end
- end
- end
- end
- function newLine(x1, y1, title)
- term.setCursorPos(x1, y1)
- if title == "stretch" then
- print("--------------------------------------------------")
- else
- write(title)
- end
- end
- function drawDesktop()
- term.setCursorPos(1,1)
- files = fs.list("windows/programs")
- for n=1,#files do
- local x2, y2 = term.getCursorPos()
- if not fs.isDir("windows/programs/" ..files[n]) then
- newButton(1, y2+1, "-+-+-+-+", files[n], "windows/programs/")
- newLine(1, y2+2, " " ..files[n])
- end
- end
- end
- function drawButtons()
- newLine(1, y-1, "stretch")
- if running == "start" then
- newButton(1, y, "Start | ", "start", path)
- else
- newButton(1, y, "Start | " ..running, "start", path)
- end
- end
- function reDraw(derp)
- if pirated == false then
- term.clear()
- if running == "" or running == "start" then
- drawDesktop()
- end
- drawButtons()
- term.setCursorPos(1,1)
- if running == "" then
- if isStart == true then
- start()
- end
- else
- shell.run(path.. "" ..running)
- if isStart == true then
- start()
- end
- end
- term.setCursorPos(currentX, currentY)
- write(Cursor)
- end
- end
- function piratecheck()
- rednet.open("top")
- rednet.send(744, "IDcheck")
- id, message = rednet.receive()
- if id == 744 then
- if message == "faduejdjs" then
- pirated = false
- reDraw(running)
- else
- print("Pirated version detected! Rebooting!")
- sleep(3)
- os.reboot()
- end
- end
- end
- --piratecheck()
- while true do
- reDraw(running)
- local e,key = os.pullEvent( "key" )
- local a,char = os.pullEvent( "char" )
- if key == 17 or key == 200 then --up
- if currentY > 1 then
- currentY = currentY -1
- end
- reDraw(running)
- elseif key == 31 or key == 208 then --down
- if currentY < y then
- currentY = currentY +1
- end
- reDraw(running)
- elseif key == 203 or key == 30 then --left
- if currentX > 1 then
- currentX = currentX -1
- end
- reDraw(running)
- elseif key == 205 or key == 32 then --right
- if currentX < x-1 then
- currentX = currentX +1
- end
- reDraw(running)
- elseif key == 28 then
- pressed = true;
- reDraw(running)
- sleep(0.0001)
- pressed = false;
- end
- oldkey = char
- end
Add Comment
Please, Sign In to add comment