RedChat

Chat over rednet with usernames. I know other people also made similar programs, but i made my own :(/>/>/>/>.
To set username, go to "settings"->"set nick".
Pastebin: Zp7bAkH .
Screenshots:
SpoilerClick for bigger:
Computer 1:[attachment=104:Comp1.png]
Computer 2:[attachment=105:Comp2.png]
Code:
Spoiler


s = 1
s2 = 1
nicks = {""}
function wtt() -- WTT ---------- Write top text (It should be print :)/>/>/>/>)--
x1,y1 = term.getCursorPos()
term.setCursorPos(1,1)
print(topText)
term.setCursorPos(x1,y1)
end
function run()  --RUN -------- The chat part--
running = true
term.clear()
wtt()
ft = true
while running do
if a == "char" then
--write(:)/>/>/>/>
cs = cs..b
elseif a == "key" and b == 28 and ft == false then
rednet.broadcast(cs)
atm("Me: "..cs)
cs = ""
elseif a == "key" and b == 56 then
running = false
menu()
elseif a == "key" and b == 14 then
cs = string.sub(cs,1,string.len(cs)-1)
elseif a == "rednet_message" then
if string.sub(c,1,9) == ":SETNICK " then
nicks[b] = string.sub(c,10,-1)
atm(b.."'s nick is now "..nicks[b])
else
if nicks[b] then
atm(nicks[b].."("..b.."): "..c)
else
atm(b..": "..c)
end
end
end
term.setCursorPos(1,2)
for i=1, #m do
term.clearLine()
print(m[i])
end
term.setCursorPos(1,2+#m)
term.clearLine()
write(">"..cs)
a,b,c = os.pullEvent()
if ft then ft = not ft end
end
end
menulist1 = {"Start","Settings","Exit"}
menulist2 = {"Set nick","Help"}
function exit()   -- EXIT -----------Exits the program--
term.clear()
term.setCursorPos(1,1)
--os.exit()
end
function changeSettings(setting) -- CHANGESETTINGS ----settings...--
if setting == 1 then
shell.run("clear")
wtt()
print("")
write("Choose nick: ")
nick = read()
rednet.broadcast(":SETNICK "..nick)
print("Setting nick...")
sleep(1)
print("Done.")
sleep(1)
run()
elseif setting == 2 then
term.clear()
term.setCursorPos(1,1)
wtt()
print("")
print("To start chatting, use START.")
print("To set nick, go to SETTINGS -> SET NICK")
print("To go back to menu when chatting, use the ALT key.")
print("Have fun!")
os.pullEvent()
menu()
end
end
function menu()  -- MENU -----------
wtt()
term.setCursorPos(1,2)
term.clear()
mr = true
while mr do
term.setCursorPos(1,2)
for i = 1, #menulist1 do
if s == i then
print(">"..menulist1[i].."<")
else
print(" "..menulist1[i].." ")
end
end
a,b = os.pullEvent()
if a == "key" and b == 28 then
n = s -- action...
if n == 1 then
run()
elseif n == 2 then
term.clear()
wtt()
term.setCursorPos(1,2)
mr = true
while mr do
term.setCursorPos(1,2)
for i = 1, #menulist2 do
if s2 == i then
print(">"..menulist2[i].."<")
else
print(" "..menulist2[i].." ")
end
end
a,b = os.pullEvent()
if a == "key" and b == 28 then
changeSettings(s2)
mr = false
elseif a == "key" and b == 200 and s2 > 1 then
s2 = s2 - 1
elseif a == "key" and b == 208 and s2 < #menulist2 then
s2 = s2 + 1
end
end
elseif n == 3 then
exit()
end
mr = false
elseif a == "key" and b == 200 and s > 1 then
s = s - 1
elseif a == "key" and b == 208 and s < #menulist1 then
s = s + 1
end
end
end


topText = "REDCHAT V1.0 BY KAMNXT"
function atm(text) -- ATM (Add to "m")---------
for i=1, #m-1 do
m[i] = m[i+1]
end
m[#m] = textutils.formatTime(os.time(),true)..": "..text
end
-- END OF FUNCTIONS! ----------------------------
x,y = term.getSize()
m = {"","","","","","",""}
y = y-2
for i=1, y do
m[i] = ""
end
shell.run("clear")
print(topText)
cs = ""
running = true
sides = rs.getSides() --Finds rednet modem
for i =1, #sides do
if peripheral.isPresent(sides[i]) then
if peripheral.getType(sides[i]) then
modemside = sides[i]
end
end
end
print(id)
if modemside then
rednet.open(modemside)
menu()
else print("No modem found.")
end

Disk cloner:
Copies all the files from a disk to another one, and sets the label on the blank one to the label on the original one. Insert the original disk into a disk drive on the left and a blank one on the right.
Pastebin: Msmr8XsD .
Spoiler


d1 = disk.getMountPath("left")
d2 = disk.getMountPath("right")
if disk.isPresent("left") and disk.isPresent("right") then
d1l = fs.list(d1)
d2l = fs.list(d2)
if #d2l > 0 then
print("Right disk not empty.")
sleep(2)
else
for i=1, #d1l do
fs.copy(d1.."/"..d1l[i],d2.."/"..d1l[i])
end
disk.setLabel("right",disk.getLabel("left"))
print("Done.")
end
elseif disk.isPresent("right") then
print("No original disk.")
elseif disk.isPresent("left") then
print("No blank disk.")
else
print("No disks found.")
end