Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("maxintosh/mAPI")
- --Design
- term.setBackgroundColor(colors[col])
- term.clear()
- mAPI.drawWindow(2,2,colWind)
- term.setBackgroundColor(colors[colWind])
- term.setTextColor(colors[colText])
- paintutils.drawBox(3,3,49,3,colors.white)
- paintutils.drawPixel(25,3,colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(10,3)
- write("contacts")
- term.setCursorPos(35,3)
- write("chats")
- --Click test
- while true do
- event,n,x,y=os.pullEvent("mouse_click")
- if x==50 and y==2 then
- error()
- end
- --Contacts
- if y==3 and x<25 then
- paintutils.drawFilledBox(3,4,49,17,colors[colWind])
- term.setCursorPos(48,4)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.green)
- write("+")
- term.setBackgroundColor(colors[colWind])
- term.setCursorPos(4,4)
- write("name")
- term.setCursorPos(21,4)
- write("ingame name")
- term.setCursorPos(44,4)
- write("ID")
- --loading contacts
- Count=6
- yContact={}
- for id=1,100 do
- if fs.exists("maxintosh/"..currentUser.."/contacts/"..id) then
- file=fs.open("maxintosh/"..currentUser.."/contacts/"..id,"r")
- name=file.readLine()
- name=file.readLine()
- ingameName=file.readLine()
- term.setCursorPos(4,Count)
- write(name)
- term.setCursorPos(22,Count)
- write(ingameName)
- term.setCursorPos(44,Count)
- write(id)
- term.setCursorPos(48,Count)
- write("x")
- yContact[Count]=id
- Count=Count+1
- file.close()
- end
- end
- --click
- while true do
- event,n,x,y=os.pullEvent("mouse_click")
- if x==50 and y==2 then
- error()
- end
- if y==3 then
- shell.run(shell.getRunningProgram())
- error()
- end
- if x==48 and not(y==4) then
- if yContact[y]==nil then
- else
- mAPI.drawWindow(4,4,colWind)
- term.setTextColor(colors[colText])
- term.setBackgroundColor(colors[colWind])
- term.setCursorPos(6,6)
- write("new name:")
- term.setCursorPos(6,8)
- write("new ingame name:")
- term.setCursorPos(6,10)
- write("new ID:")
- term.setCursorPos(23,14)
- write("delete")
- file=fs.open("maxintosh/"..currentUser.."/contacts/"..yContact[y],"r")
- newID=file.readLine()
- oldID=newID
- newName=file.readLine()
- newIngame=file.readLine()
- file.close()
- while true do
- event,n,x,y=os.pullEvent("mouse_click")
- if x==48 and y==4 then
- fs.delete("maxintosh/"..currentUser.."/contacts/"..oldID)
- file=fs.open("maxintosh/"..currentUser.."/contacts/"..newID,"w")
- file.writeLine(newID)
- file.writeLine(newName)
- file.writeLine(newIngame)
- file.close()
- shell.run(shell.getRunningProgram())
- error()
- end
- if y==6 then
- paintutils.drawBox(16,6,47,6,colors[colWind])
- term.setCursorPos(16,6)
- newName=read()
- end
- if y==8 then
- paintutils.drawFilledBox(23,8,47,8,colors[colWind])
- term.setCursorPos(23,8)
- newIngame=read()
- end
- if y==10 then
- paintutils.drawBox(14,10,47,10)
- term.setCursorPos(14,10)
- newID=read()
- end
- if y==14 then
- fs.delete("maxintosh/"..currentUser.."/contacts/"..oldID)
- shell.run(shell.getRunningProgram())
- error()
- end
- end
- end
- end
- if x==48 and y==4 then
- if not(fs.exists("maxintosh/"..currentUser.."/contacts")) then
- fs.makeDir("maxintosh/"..currentUser.."/contacts")
- end
- mAPI.drawWindow(4,4,colWind)
- term.setTextColor(colors[colText])
- term.setBackgroundColor(colors[colWind])
- term.setCursorPos(6,6)
- write("name:")
- term.setCursorPos(6,8)
- write("ingame name:")
- term.setCursorPos(6,10)
- write("ID:")
- term.setCursorPos(23,14)
- write("finish")
- while true do
- event,n,x,y=os.pullEvent("mouse_click")
- if x==48 and y==4 then
- shell.run(shell.getRunningProgram())
- error()
- end
- if y==6 then
- paintutils.drawBox(12,6,47,6,colors[colWind])
- term.setCursorPos(12,6)
- newName=read()
- end
- if y==8 then
- paintutils.drawBox(19,8,47,8,colors[colWind])
- term.setCursorPos(19,8)
- newIngame=read()
- end
- if y==10 then
- paintutils.drawBox(10,10,47,10,colors[colWind])
- term.setCursorPos(10,10)
- newID=read()
- end
- if y==14 then
- file=fs.open("maxintosh/"..currentUser.."/contacts/"..newID,"w")
- file.writeLine(newID)
- file.writeLine(newName)
- file.writeLine(newIngame)
- file.close()
- shell.run(shell.getRunningProgram())
- error()
- end
- end
- end
- end
- end
- --Chats
- paintutils.drawFilledBox(3,4,49,17,colors[colWind])
- paintutils.drawFilledBox(3,4,18,17,colors.lightGray)
- paintutils.drawBox(18,4,18,17,colors.black)
- paintutils.drawBox(3,4,49,4,colors.black)
- term.setTextColor(colors.black)
- --checking for new messages
- found=false
- notification={}
- timer=os.startTimer(3)
- rednet.open("top")
- rednet.send(server,"receive")
- while found==false do
- event,a,b=os.pullEvent()
- if event=="timer" then
- term.setCursorPos(28,7)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.black)
- write("no connection")
- found=true
- elseif a==server and b=="noMsg" then
- found=true
- term.setCursorPos(27,7)
- term.setBackgroundColor(colors.green)
- term.setTextColor(colors.black)
- write("no new Messages")
- elseif a==server and not(b=="noMsg") then
- found=true
- text={}
- text=b
- event,a,b=os.pullEvent("rednet_message")
- fromid={}
- fromid=b
- l=table.maxn(fromid)
- i=1
- term.setCursorPos(27,7)
- term.setBackgroundColor(colors.green)
- term.setTextColor(colors.black)
- write(l.." new Messages")
- while i<=l do
- file=fs.open("maxintosh/"..currentUser.."/contacts/chats/"..(tonumber(fromid[i])+0),"a")
- file.writeLine("r")
- file.writeLine(text[i])
- file.close()
- notification[fromid[i]+0]=true
- i=i+1
- end
- end
- end
- rednet.close("top")
- --loading contacts on left side
- yToID={}
- yCount=5
- for i=1,100 do
- if fs.exists("maxintosh/"..currentUser.."/contacts/"..i) then
- file=fs.open("maxintosh/"..currentUser.."/contacts/"..i,"r")
- name=file.readLine()
- name=file.readLine()
- file.close()
- if notification[i]==true then
- paintutils.drawPixel(2,yCount,colors.green)
- else
- paintutils.drawPixel(2,yCount,colors.black)
- end
- if math.fmod(yCount,2)==0 then
- term.setBackgroundColor(colors.blue)
- paintutils.drawBox(3,yCount,17,yCount,colors.blue)
- else
- term.setBackgroundColor(colors.lightBlue)
- paintutils.drawBox(3,yCount,17,yCount,colors.lightBlue)
- end
- term.setCursorPos(3.5,yCount)
- write(name)
- yToID[yCount]=i
- yCount=yCount+1
- end
- end
- --click
- while true do
- event,n,x,y=os.pullEvent("mouse_click")
- --X
- if x==50 and y==2 then
- error()
- end
- --Oben
- if y==3 then
- shell.run(shell.getRunningProgram())
- error()
- end
- --chat-Leiste links
- if x>2 and x<19 then
- paintutils.drawPixel(2,y,colors.black)
- id=yToID[y]
- f=fs.open("maxintosh/"..currentUser.."/contacts/"..id,"r")
- cID=f.readLine()
- cName=f.readLine()
- cIngame=f.readLine()
- f.close()
- paintutils.drawFilledBox(19,5,49,17,colors[colWind])
- paintutils.drawBox(19,5,49,5,colors.white)
- lenght=string.len(cName)
- term.setCursorPos((math.floor((30-lenght)/2)+19),5)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.orange)
- write(cName)
- term.setCursorPos(44,5)
- term.setTextColor(colors.red)
- write("clear")
- paintutils.drawBox(19,17,49,17,colors.lightGray)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(30,17)
- write("--type--")
- if fs.exists("maxintosh/"..currentUser.."/contacts/chats/"..cID) then
- else
- file=fs.open("maxintosh/"..currentUser.."/contacts/chats/"..cID,"a")
- file.writeLine("a")
- file.writeLine("start of the chat")
- file.close()
- end
- chatDataFrom={}
- chatDataText={}
- f=fs.open("maxintosh/"..currentUser.."/contacts/chats/"..cID,"r")
- chatDataFrom[1]=f.readLine()
- chatDataText[1]=f.readLine()
- i=2
- while not(chatDataFrom[i-1]==nil) do
- chatDataFrom[i]=f.readLine()
- chatDataText[i]=f.readLine()
- i=i+1
- end
- f.close()
- maxMsg=i-2
- while maxMsg>0 do
- if chatDataFrom[maxMsg]=="s" then
- term.setBackgroundColor(colors.green)
- textLenght=string.len(chatDataText[maxMsg])
- add=31-textLenght
- elseif chatDataFrom[maxMsg]=="r" then
- term.setBackgroundColor(colors.white)
- add=0
- else
- term.setBackgroundColor(colors.red)
- add=7
- end
- term.setCursorPos(19+add,maxMsg+5)
- term.setTextColor(colors.black)
- write(chatDataText[maxMsg])
- maxMsg=maxMsg-1
- end
- event,n,x,y=os.pullEvent("mouse_click")
- if x>18 and y==17 then
- paintutils.drawBox(19,17,49,17,colors.white)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(20,17)
- insertedMsg=read()
- rednet.open("top")
- rednet.send(server,"send")
- rednet.send(server,cID)
- rednet.send(server,insertedMsg)
- rednet.close("top")
- paintutils.drawBox(19,17,49,17,colors.lightGray)
- f=fs.open("maxintosh/"..currentUser.."/contacts/chats/"..cID,"a")
- f.writeLine("s")
- f.writeLine(insertedMsg)
- f.close()
- end
- if x==50 and y==2 then
- error()
- end
- if x>43 and y==5 then
- fs.delete("maxintosh/"..currentUser.."/contacts/chats/"..cID)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment